CLI Network Speedtest

CLI Network Speedtest

I google searched “CLI internet speed test this morning and came across two pretty cool things. One is a little command-line executable from Ookla That you can run from the terminal. It’s not signed so you’ll need to unzip the archive then right-click on ”speedtest“ and select ”Open". Approve with admin credentials and it’ll open the Terminal and run. You should then be able to run it from the command line by typing /path/to/speedtest.

You could alse type xattr -d com.apple.quarantine /path/to/speedtest to remove the quaranting flag then run the program from the terminal.

The second cool thing is that Monterey includes a built-in speed test tool. Type networkQuality -h to list the possible flags or man networkQuality to get the full man page. Most importantly, type:

networkQuality -v

To get a quick network speed check, along with some other cool info like start and end time and OS version. OS Verion? Weird. I guess there’s somewhere else to check OS version from the command line now.

Apple has documented the tool here and there’s a bunch of stuff that I don’t understand, but looks neat and useful here, which I’m adding to my list of 9 million things to learn more about.

Advertisement

Adding an AirPrint Printer the Easy Way

Update: 2022-2-13

You’ll have to forgive me if this is a little non-sensical, but I just spent seven or eight hours writing stuff based on a misunderstanding of work that had come previously 😐 . This was my fault for misreading what apizz was doing with his script that he wrote on October 30, 2019. I just realized tonight that he’d followed it up with this from May 26th, 2021, and the follow up script helped something click in my brain that hadn’t before.

My interpretation of what apizz was doing was that he was using the script in the 2019 post to generate PPD files for each of the printer models he was managing and deploying those into place along with icon files when deploying a printer. I don’t know why I read it that way, but that’s what I mean in this post when I say it felt like he was doing things the old way(deploying drivers along with install scripts). He was not (I don’t think but I don’t know what’s real anymore).

Tonight, after looking through the second script he posted in 2021 to fix the icon issue, I realized my assumption would have been a ridiculous way to handle it and that what he’s actually doing is much simpler: just run the script to generate the PPD on the device that you’re adding the printer to and add the printer in the same script. The only thing left to manage at that point is the script that’s generating the PPD.

apizz was kind enough to read this post and rightly criticized a number of points that I made, mostly in my sections titled “The Failures”(this was always intended to indicate my own failures, not anyone else’s, I’m realizing now that that was a poor choice of section heading title) and “Another Option”.

Concerning the failures, again: they were entirely failures of understanding and implementation of my own making. Concerning the other option, apizz mentioned in his comment that it resembled his own solution. I’d argue that that’s like saying an ingredient list for lasagna resembles the final product. The point I was trying to make was that someone could, if they wanted, start with the lpadmin command that I mentioned and build something workable. Which apizz did. In 2019. Then made it better in 2021.

I’m up to 2000 words written for this blog post (600 of which are about to get deleted because they’re embarrassing because I still hadn’t understood what I’d misunderstood about apizz’s post. Man I sure hope I’ve understood it now), which is entirely too many words when all I really needed to say was:

“Hey folks, I found a neat thing: open -a "/System/Library/CoreServices/AddPrinter.app" ipp://printerHostName“.

Sorry, apizz. Thanks for taking the time to help me be a better writer and better Mac admin.

All that said, I’d skip “The Failures” and “Another Option” down below and if you think what I’ve written is dumb go check out apizz’s posts because he can show you how to deploy a printer without user interaction. Mine is for Self Service only.

Original Post:

If you want to get right to the nitty-gritty and bypass +/- 1000 words about a one-line shell command you can check out my script on GitHub. If you want to know why I did what I did, it beats me but you may find some insights below.

This week I’ve at last finalized a solution to a problem that’s bedeviled me for four or five years. When I first started as a baby Mac Admin in the second half of 20151 adding printers with a tool like Munki or Jamf was mostly a solved problem.

Things have come a long way over the last six and a half years, though, and the methods that were best practice back then have all pretty much stopped working. Printer drivers were deprecated or are being deprecated or I don’t even know anymore, and heaven help you if your printer software has 32-bit components. Hopefully my suggestions below provide you a shortcut and your journey is shorter than mine.

The Problem

I needed a way to add printers to Jamf Self Service so my coworkers can add relevant printers for themselves easily whenever necessary. I needed the method I settled on to be able to add the printers as AirPrint printers using the Internet Printing Protocol to simplify the installation and so there wouldn’t be any extra packages to install and manage.

The Failures

You’re get to skip through years of frustration in 4 paragraphs. Enjoy.

Failure Number One

I came across a number of options over the last three or four years that I couldn’t get working reliably in my environment. Things like this thread on Jamf Nation and this one from Apizz led me down months-long rabbit trails trying to get ippfind and ipp2ppd to give me what I wanted.

To be quite frank, I think the problem with those solutions was that they were trying to deal with AirPrint in an old way.

Failure Number Two

The other option that I found unworkable was adding printers with Configuration Profiles through my MDM solution(Jamf). Adding printers to Jamf was a pain and rarely resulted in a working, deployable configuration for me.

It’s entirely likely that I was holding it wrong adding the printers incorrectly but this was another solution I worked on for months and couldn’t get working reliably.

The Solution

Having stared at the problem long enough I finally had a bit of an unexpected thought: “I wonder if anything in macOS is registered to handle ipp:// URLs”.

In a moment of pure desperation I typed the ipp:// URL for the department printer into the address bar in Safari and

Confirmation dialog box in Safari to open AddPrinter.app.
Open in AddPrinter.app

WHAT?!

I clicked “Allow” and

Confirmation dialog box for communicating with the printer.
Clicking “Continue” will communicate with the printer.

WHAT?!?!

I clicked “Continue” and

Printer added to Printers & Scanners Preferences pane.
My wife’s printer. Successfully added.

Well that was easy. I could automate that. Some of you may be seeing what I missed, but that was good enough for me. I rolled right ahead with Safari, problem solved:

open -a "Safari" ipp://deptPrinterHostName

(don’t use that command, the good one comes later)

There was my department printer added to my computer, pretty icon and all. It even added the fax machine2!

I created a policy for each of the printers I needed using the Files and Processes option to run that command and shoved them all into Self Service.

Refinement

I was happy as a clam till a few months later. Towards the beginning of February, 2022 I was cleaning up some policies in Jamf, thinking about how awesome I was and remembering how pleased I was with my printer solution.

I mentioned it to my buddy Adam3. When I showed Adam the command I was using, Adam asked a rather insightful question: “Why Safari?”

I don’t know, Adam. Gimme a minute to re-think everything I believe in.

With my genius firmly debunked I tried a couple of commands off the top of my head4 before opening the Add Printer app5 and pulling up Activity Monitor. Sort by name, double click the Add Printer process and select the “Open Files and Ports” tab to reveal the droid we’re looking for: /System/Library/CoreServices/AddPrinter.app. And sure enough, AddPrinter.app is registered to handle ipp:// URLs. Hooray!

That gives us the rather tidy

open -a "/System/Library/CoreServices/AddPrinter.app" ipp://printerHostName

to add a printer. Run the command and confirm you want to connect to the printer. The Add Printer app opens, connects to the printer and closes again.

Super clean and simple and it only took me like 5 years to figure it out.


Another Option

In getting this all typed up I ran across the following:

lpadmin -p BrotherPrinter -E -v ipp://brw8cc84b465a44.local/ipp/print -m everywhere

This works but has a couple of drawbacks I don’t like:

  • It adds the printer with a generic printer icon. This is trivial, but I think it does make for a worse experience for my coworkers, especially if they have multiple printers
  • It adds the printer using the IPP Everywhere PPD which seems to not pull as much info from the printer as my method. This affects little things like supply level bars being black instead of the color of toner they represent. Again, trivial things but the AirPrint method seems to make for a nicer experience

One advantage of using the lpadmin command is that it doesn’t require user interaction. If you need to add printers automatically with a script it might be worth investigating that a little further to see if you can specify some of those additional details that will make the user experience a little better. I found the lpadmin command here. That link and this one would be a good place to start your research.

For my part I’m going to stick with:

open -a "/System/Library/CoreServices/AddPrinter.app" ipp://printerHostName


Footnotes

1: I’m now a toddler Mac Admin. We mature slowly. ⤴︎

2: I don’t actually care about the fax machine but maybe you do? ⤴︎

3: open -a "Sytem Preferences" ipp://printerHostName; open -a "Printers & Scanners" ipp://printerHostName; and open -a "Add Printer" ipp://printerHostName if you must know. ⤴︎

4: You probably know Adam if you’re reading this. ⤴︎

5: System Preferences > Printers & Scanners > “+” ⤴︎

Matias Wired Keyboard for Mac

The Problem

I’ve been searching for a good Mac keyboard to deploy to laptop workstations for a few years now. I think I’ve finally settled on one that is laid out in the traditional Apple configuration, has the media key shortcuts printed at the top, and includes a 10-key pad on the right(i.e. not a 60% or ten-keyless keyboard).

The Solution

Matias has sold the Wired Aluminum Keyboard for Mac for $59 for a while now, and while that keyboard is as close as you can get to the excellent, but discontinued, Apple Aluminum Keyboard with Numeric Keypad these days, $59 felt like a bit too much as our default keyboard. Enter the Matias Wired Keyboard for Mac for $39. To keep the cost down they’ve swapped the aluminum frame around the keys to a plastic frame.

The Details

I typed a couple hundred words this afternoon on the new keyboard to get a feel for it. I adjusted pretty quickly to it from my normal mechanical keyboard. Again, these Matias keyboards are the closest I’ve found to the old Apple butterfly switches. I think they feel pretty good, if a little on the squishy side.

I didn’t find the switches on the plastic version of the keyboard to be any different from those on the aluminum keyboard, they’re probably the same switches. Matias calls this a “budget version” of their aluminum keyboard but don’t mention if they’re using the same switches.

A couple of caveats are worth mentioning:

First, the keyboard is plastic. It doesn’t have the rigidity that the aluminum versions have. If you pick it up with a hand at either end and twist it will flex like any other long piece of plastic.

Second, and this is due to that same flex, there’s a bit of an extra bounce to the keys when you bottom out. The keyboard has pretty substantial rubber feet, which keep it in place nicely, but also provide a little space for the keyboard to bend and spring back as I hit the keys. I didn’t find it unpleasant, but it was noticeable when transitioning from a different keyboard.

Conclusions

I’ll be purchasing a bunch of these keyboards over the next few years. In my experience, most of my coworkers aren’t as remotely interested in getting the exact feel they want out of their keyboards and. Or maybe they’re just more courteous and don’t want to bang away on mechanical keyboards in a cube farm. Either way, these keyboards will provide a lot of extra functionality at their office workstations and keep them from having to remember which button on the keyboard is the Command key. I think these will make them a lot happier than the hand-me-down Lenovo and HP keyboards we’ve been handing out.

These keyboard names though. Can’t we get like a USB Fireball or a Bluetooth Thunderbolt?