Posts Tagged Mac OS X Client

Removing Quarantine from Large Numbers of Files on Mac OS X

So,  you’ve wound up with a huge number of files, folders and sub-folders with a extended attribute?  (I’ll assume you already know that Mac OS X puts this on downloaded files for security reasons.  This is the thing that triggers the OS to ask you if you’re sure you want to open something that came from the internet.)  See my other recent entry on why this may have happened if you don’t know.

To remove these will take some scripting. The only thing that removes them that is provided in the OS is the command-line tool “xattr”.   Unfortunately, you can’t just specify a folder to cleanse recursively.

I did experiment with xattr and some scripts for it that I found on the internet.  But they ran terribly slowly.  Depending on the situation, they may produce a lot of “no such attribute” errors which made things even slower. After watching one such script grind on for a while,  I ran

ls -laR | grep “@” | wc -l

and it promptly showed 600+ items with extended attributes still remaining.

I finally hit upon this shell script which did the whole thing in a blink for everything in the current working directory:

for f in find ./ -type d
cd “$f”
xattr -d *

Calling xattr with “*” cleans out an entire directory very quickly.  It may still generate errors if some of the files/folders do not have a matching extended attribute.  The results of “find ./ -type d” are only the directories in the tree, so we call xattr once for each directory instead of once for each file.

I was hoping to make this into an easier-to-use script for use in a drag-and-drop applescript application, but I ran out of time.


Prevent Quarantine on Archives from getting Expanded

Today I had a problem which I thought was related to having the extended attribute on a folder with a large number of files and subfolders.

In the end, I had removed the quarantine from them all (topic for another post).  It wasn’t the source of the problem at hand, but it did wind up with an important lesson:  remove quarantine from any .zip file before decompressing it.  Apple’s “Archive Utility” (the program that does the decompression) will maintain the quarantine attribute through every file, directory, and sub-directory.

If you’ve got a directory with a huge number of files set with this, look for my blog post on removing them all.

Tags: , , , ,

Controlling Macs with No Keyboard: CD Tray

Titling this one was a little harder than most somehow.   I guess part of it is that there are so many ways to express this.

Today I needed to use a Mac whose monitor got … appropriated… by my family for other purposes. I just needed to use a piece of software there that is only needed once in a … well, almost never.

To get to the point, Apple’s Remote Desktop product is nice, and offers good control, but doesn’t have anything I could find that would eject the tray.  If a disk had been already in it, it could have been used to eject that of course.

Anyway,  the first solution I found is a command-line tool in the Mac:  drutil.  Just connect to the “headless” Mac with SSH in a terminal (there are plenty of how-to’s available via Google) then type this:

drutil -drive 1 tray open

The tray popped out and my problem is solved.

I tried putting this into an AppleScript application so that I could put it on the dock. Then it would only be a click away.  A quick test showed that this does nothing if a disk is actually mounted from the drive.  No error message is generated. It also became clear that this command is literal, it will only open the tray.   To close the tray, I had to issue the reverse command:

drutil -drive 1 tray close

(I suppose that’ll require another AppleScript application.)

If you’d like one, just type the following line into a blank document in the AppleScript Editor program.  The quotes are necessary to send the whole thing together,  othewise AppleScript will try to interpret each word in the line.

do shell script “drutil -drive 1 tray open”

I did search around to see if there was an open/close command.  After all, the eject button on the keyboard gets it right. (when one is connected) and so does the drive’s button (when its not covered up by the Mac case.)  But I didn’t turn up anything in the few minutes available.


Tags: , ,

Is your Apple warranty still active?

After helping the great folks at my daughter’s school with an external monitor issue, it seemed the problem was in the Mac itself. So naturally, questions about the status of the warranty came up.  I knew that all the Apple Authorized service centers can look up the status, but getting someone on the phone isn’t necessarily easy or convenient (especially during off-hours.)

So, Googling (sp?) for the answer turned up a page I had not found before (ok, I had not really looked in a long time) :

You can put in your serial number and get an answer immediately about the status of your warranty.

Things to know:

It can be a real pain to find and read the really tiny serial number sticker on a modern Mac, iPod or iPhone (or maybe its just my eyes going downhill).  Much easier,  you can copy and past the serial number from the “System Profiler” utility. Its in the “Hardware Overview” information which comes up first by default.  You can find the System Profiler in the “Utilities” folder in the “Applications” folder,  or you can go to the Apple Menu, select “About This Mac”, then press the “More Info” button.

If you bought an AppleCare extended warranty, but the site only shows a 1-year warranty, it may be that the extended warranty didn’t get registered. (The registration instructions should be in the box.) It may or may not have been automatically registered if you bought the computer and AppleCare together at an Apple Store.  You have to buy an AppleCare extended warranty while the original 1-year warranty is still good.  If you bought it, but didn’t register it, you may have to call Apple or talk to someone in an Apple store and show them the purchase receipt showing both the Mac purchase and the AppleCare purchase.  Someone can then re-instate the extended warranty.

Tags: , , ,

Computer Detective: Case of the Reluctant Printer Driver

It was a dark and stormy night.  Well in the office around the misbehaving Mac anyway.   Outside was bright and sunny. A typical day here.

(OK, no more novel-noir)

I had been called in to help install printer drivers on a new Mac Laptop (running 10.5.2).  The good folks at the company had done everything right in trying to install them, but they never worked.   A quick re-try showed me that the description on the phone had been correct. The installation reported no errors, but the printer was still unusable. Read the rest of this entry »

Tags: , , , ,