Remove a printer installed by Profile Manager or MCX from the command line (or remote ARD command)

When Profile Manager installs a printer, the CUPS queue name doesn’t match what the user sees. You can get a list of those queues by typing lpstat -s. To remove the printer by the name you define in Profile Manager with a script, you’ll need to find out the CUPS name.

Here’s a one-liner to remove a printer that was automatically installed with Profile Manager:

export ptr="PRINTERNAME";lpstat -s | awk "\$4 ~ /$ptr/ {print \$3}" | tr -d : | xargs lpadmin -x

Just replace PRINTERNAME with the correct queue name.

Remove a printer or update a printer in Mac OS X Server Profile Manager

If you modify a printer in Mac OS X Server’s Profile Manager, the changes don’t always get updated in my experience. To get the updates, you need to remove the row in the database that references the old printer.

In Terminal, load psql and select the correct database:

sudo psql -U _devicemgr -d devicemgr_v2m0 -h /Library/Server/ProfileManager/Config/var/PostgreSQL

Find printers with the ‘select’ SQL command:

SELECT * FROM printers;

This will select all printers. You can also use SQL’s ‘WHERE’ clause to filter the results down even more.

To remove the offending entry, use the DELETE command:

DELETE FROM printers where id=[the 'id' column obtained from the previous list]

As soon as I did this, the new printer populated in Profile Manager.

Signing iOS mobileconfig files with your certificate

If you’ve ever used Apple’s iPhone Configuration Utility, you’ve probably noticed that it says ‘Unsigned’ when you send the .mobileconfig file to your device. To sign the profile, export or email the config file to yourself, have your certificate files handy, and type the following:

openssl smime \
-sign \
-signer your-cert.pem \
-inkey your-priv-key.pem \
-certfile TheCertChain.pem \
-nodetach \
-outform der \
-in ConfigProfile.mobileconfig \
-out ConfigProfile_signed.mobileconfig

The files you’ll need are:

your-cert.pem – this is the certificate you’ve been issued
your-priv-key.pem – this is your private key
TheCertChain.pem – this is the certificate chain (optional, in some cases)
ConfigProfile.mobileconfig – This is the unsigned copy of your configuration profile

The original instructions are located here.

Fixing Mac OS X 10.6’s ping command (aka, removing Request timeout for icmp_seq #)

If you are like me, and annoyed that OS X 10.6’s ping command displays the following text when it cannot reach a host:

Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2

Then you’ll be happy for the fix. You can either download the source code to the ping command from Apple and edit it yourself, or you can download my pre-compiled copy.

If you choose to edit it yourself, you’ll want to comment out lines 977 and 978 so they look like this:

// if (!(options & F_QUIET))
// printf("Request timeout for icmp_seq %ld\n", ntransmitted - 2);

Then just type ‘gcc ping.c’ and you’ll end up with a file called a.out, which you can use to replace /sbin/ping, or put in your local ~/bin directory if you’ve got one.

Adding Printers to OS X from the Command Line

After a little searching, I found out you can add printers to OS X from the command line using this syntax:

lpadmin -p Printer_Name -L "Printer Location" -E -v lpd://x.x.x.x -P /Library/Printers/PPDs/Contents/Resources/en.lproj/Printer_Driver.gz

If you don’t specify the -P option, it will not show up in your Print or Printer Setup dialogs. If you want to include the generic PPD, it is located here:

/System/Library/Frameworks/ApplicationServices.framework/Versions \ /A/Frameworks/PrintCore.framework/Versions/A/Resources/Generic.ppd

That path is all one line, with no spaces.

Leopard’s SSH Agent not working

My Leopard SSH agent was not working after upgrading a Macbook Pro. I was using a few other applications in the past to manage my SSH keys – in fact, I didn’t even know this was a feature until the new install on a Mac Pro worked without me installing the ‘keychain’ app from fink, or a number of other solutions that I had tried in the past.

To fix this, I had to edit the ~/.MacOSX/environment.plist file. In that file, there is an entry for SSH_AUTH_SOCK which needs to be removed. I just removed the the section that looked like:


The text may differ slightly on your computer.

Leopard Error -5002 when connecting to AFP shares

When connecting to AFP shares in the new Mac OS X 10.5 (Leopard), you may get a -5002 error when the server only supports clear text passwords. To resolve, either disable clear text passwords on the server side, or change the following plist:


You need to change the afp_cleartext_allow value to “Yes” “true” or “1” (depending on the current values you see, either “false” or a “0”).

Here’s an excerpt from my file:

<true />

Online Remote Backup with Mozy

Mozy is an online backup service – right now I’m using it to backup roughly 1.6GB of data. You can backup 2GB for free, or pay around $5 per month for unlimited backup, which I am thinking about upgrading to.  Recently they released a Mac client which makes this a better option for me.  They also offer a commercial version of the service which called MozyPro.

read more | digg story

InDesign Crashes Whilte Printing on Mac OS X

Sometimes, Adobe InDesign will crash when trying to print on a user account with a networked home folder under Mac OS X. Here is the fix that I use:

ditto -rsrc /System/Library/Printers /Library/Printers

I send that command to all computers with the problem via ARD (Apple Remote Desktop) and it seems to resolve all of the issues.

If that doesn’t work, you need to copy or create a Printers folder in the current users Library folder. Drop into Terminal and type the following:

mkdir ~/Library/Printers

Those two methods have resolved most of our InDesign printing issues.

Locally Cache Mac OS X Network Login Folders

Here at the school district I was running into a problem where if several Mac OS X wireless clients logged into the network at once, everything slowed down to a crawl. After researching the problem, it looked like the user’s Library and Microsoft User Data folders were causing the problem. I tried turning on OS X’s home folder syncronization, but that didn’t work very well, and filled up our older computers fast. The solution I found was to locally cache the user’s Library and Microsoft User Data folder. To do this, create a symbolic link from the user’s networked ‘Library’ folder and point it to a local source. I chose /tmp/UserCache/username/Library. Here is the login script I created to automate the process:

#! /bin/bash

# Create local user caches of important directories
# Written by Steven Eppler 04/04/2006

export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin

# Set user variable

# This grabs the user's home directory server
input=`dscl localhost read Search/Users/$user NFSHomeDirectory`

# Or you can hardcode it...
# nethomedir="/Network/Servers/ServerName/Volume/$user"

# Check for blank nethomedir - otherwise you will delete
# the root /Library folder!
if [ """$nethomedir""" != "" ]; then

echo $user
echo $nethomedir

# Create local caching directories
mkdir /tmp/UserCache
mkdir /tmp/UserCache/$user
mkdir /tmp/UserCache/$user/Microsoft\ User\ Data
mkdir /tmp/UserCache/$user/Library

# Give everyone rights to them...
chmod -R ugo=rwx /tmp/UserCache

# Create Documents and Desktop folder (sometimes they don't exist)
mkdir $nethomedir/Documents
mkdir $nethomedir/Desktop

# Delete old folders or links
rm -rf $nethomedir/Library
rm -rf $nethomedir/Documents/Microsoft\ User\ Data

# Create new links
ln -s /tmp/UserCache/$user/Library $nethomedir/Library
ln -s /tmp/UserCache/$user/Microsoft\ User\ Data $nethomedir/Documents/Microsoft\ User\ Data