January 2008

Change a resource fork in OS X with the terminal [solved] [partially]

So one of my problems with macs has always been that you don’t have enough control over file types – programs and the OS try to outsmart you and only open what they think they can open, and no amount of fiddling or dragging and dropping would get them to open their own file if they were wrong about what type of file they thought they were.

OS X has gotten slightly better in taking the PC convention of file extensions – OS X asks if you’re sure if you want to change the extension and the icon often changes as well as the default program that opens the file when you change it.

But what about files that don’t have any extension by default, such as digital performer files? I recently had a digital performer project emailed to me with its resource fork stripped so I couldn’t open it. OS X thought it was a plain text file when I got info on it.

There have been applications since at least OS 8 that would let you modify resource forks and hex edit files such as resedit and resknife.

Now that OS X is unix though, there are some handy terminal commands to manage resource forks:

GetFileInfo [name of file]

will tell you the resource information about a file. I did this on an existing DP file and it said:

type: “PERF”
creator: “MOUP”

Then I was able to use: SetFile -c MOUP -t PERF [name of file]
to convert the plain text file back to DP again. Sweet!

Here’s a tip: If you run this command:
ls [name of file]/rsrc
and you get “No such file or directory”, the file does not have a resource fork. If you get a listing, it does have one.

Source: Mac OS X Command Line Tools Tips

-edit-
Ok I’m still having problems – DP says “An error occurred while reading from the disk. The file [name of file] was not loaded. ID = 102”.

Open a password protected zip file in OS X [solved]

The Archive Utility in OS X is great but accepts no parameters, so it’s impossible to open a password protected zip file with it. When you double click on it it says “Unable to unarchive ‘name of file.zip’ into ‘directory’. (Error 1 – Operation not permitted.) In Safari, the download will say “Decompression failed”.

Instead, open up terminal (Applications > Utilities > Terminal) and cd to the directory the zip file is in, such as:

cd ~/Downloads

or

cd ~/Desktop

Then, type:

unzip -P [password] nameoffile.zip

where nameoffile.zip is the zip file and [password] is your password.

Then you can launch the file with open nameofunzippedfile.app, or run

open .

to open the current folder in the finder to double click on your unzipped file.

Weather Dashboard Widget won’t stay open [unsolved]

My dashboard widget keeps disappearing in Leopard. I’ll load it into dashboard, hit keep, set my zipcode, and close dashboard. When I hit dashboard it loads again, but after a reboot it disappears again.
I’m not sure if this is a Leopard thing or a Google Desktop thing (it installs its own widgets). I think my configuration is messed up because once it was partially of the screen. Anyone know how to manually edit your dashboard configuration file?

-update-
I was able to hack a solution to this by running this command in terminal:
defaults write com.apple.dashboard devmode YES

That allows you to hit F12, click and hold a widget, and hit F12 again to drag it ‘out’ of widgets and onto the desktop. I did that, ran killall Dock, did the reverse, and ran killall Dock again, and it seems to be fixed. Weird.

Fail, it’s gone again.

mod_security won’t let you post [solved]

In my last post, I kept getting this error when I clicked Publish in wordpress:

Error 406, Not Acceptable. An appropriate representation of the requested resource /wp-admin/post.php could not be found on this server.

It turned out my host was running mod_security and there are certain phrases it won’t let you publish. It’s censorship, but I understand why they do it. I was talking about the most dangerous command you can run in unix:

sudo rm -rf

That’s what triggered it. I had to obfuscate the text in that entry and this one just to be able to post it. (View the source of this page to see what I mean).

If you’ve been able to post normally and suddenly you can’t and are getting this error, check for weird linux commands or files in your post that could be triggering this.

Permissions error SNAFU causes Leopard not to boot [solved]

Update: This is a bigger bug than I thought.

I just went through a nightmare of permissions errors that caused my computer to stop booting for several hours.

I was trying to share my whole hard drive, and not just my home folder. I went to System Preferences > Sharing > File Sharing and added my hard drive as a shared folder. I noticed that all my shared folders had these sharing permissions:

Me: Read & Write
Users: Read & Write
Everyone: Read Only

It freaked me out that everyone would have read access to my drive; this sounded like OS X’s guest access. (Update: This IS OS X’s guest access, sharing all of your files with no password!) Furthermore, it wouldn’t let me select no access, so I was ([RIGHTFULLY]) worried that my drive was open to the public.

In finder, I used get info and saw similar permissions:

Sharing & Permissions:
System: Read & Write
admin: Read & Write
everyone: Read only

Since it says “Sharing” above it it, I clicked the lock to unlock, authenticated, and changed everyone’s access from “read only” to “no access”. Oops.

Clearly this is for general filesystem permissions and not for AFP file sharing. First, I couldn’t install a software package (it hung on examining additional volumes…). So I tried to reboot, and my computer hung on the grey screen with the little spinny dots circling around themselves. I’d just locked my system out of itself.

I tried booting into single user mode (hold down command S) and running fsck to fix the drive. No dice.

Then I booted with the Leopard install disk. I ran Disk Utility and tried to Repair Permissions. It failed, saying something like “Unsuccessful – an internal command reported failure”. The same thing happened with Check Permissions. Crap.

I tried booting with the Techtool Deluxe CD that comes with Applecare, but apparently this isn’t even compatible with Leopard — it wouldn’t even boot to CD for me, on several tries.

I tried some of the steps from the article Unable to move, unlock, or copy an item in Mac OS X:

cd /Library/Preferences/SystemConfiguration
defaults write /Library/Preferences/SystemConfiguration/autodiskmount AutomountDisksWithoutUserLogin -bool true

Next it said to run

sh /etc/rc

but in Leopard there is no rc in /etc/. So much for that.

By the way, in the article Troubleshooting permissions issues in Mac OS X, it says

1) open Terminal
2) type: sudo rm -rf.

I don’t care what it says, NEVER RUN THIS COMMAND. That’s the most dangerous command you can run in unix.

Anyway, finally, I took it into my own hands: I booted into single user mode, and typed

chmod -R 777 /

This would recursively give everything access to everything and is the loosest form of permissions I could think of. It would screw up all of OS X’s permissions, but hopefully it would at least give OS X access to the drive again and disk utility could fix them.

Disk utility was able to run and spent a couple hours fixing permissions on the drive. After that I was able to boot again. Yay! I went back and changed the everyone permission on Macintosh HD to read only.

I got several kernel extension errors – OS X complained about not being able to load my MOTUFireWireAudio.kext extension (for my firewire audio interface), LittleSnitch.kext (little snitch), and fusefs.fs (NTFS mounter that parallels uses to mount XP drives). For the kernel extensions, I used terminal and typed:

cd /System/Library/Extensions

The extensions mentioned above had the wrong permissions (still 777). I think this is because they didn’t come with OS X by default so repair permissions didn’t know what to do with them. So I typed:

chmod -R 755 MOTUFireWireAudio.kext/
chmod -R 755 LittleSnitch.kext/

And they worked better. These files are actually OS X packages / directories, hence the trailing slash and the -R flag. My MOTU driver started working but wouldn’t open the configuration application automatically, so reinstalling it and rebooting fixed it.

You can also test your kernel extensions by running:

kextload -t MOTUFireWireAudio.kext

for example. That gave me verbose output that the permissions were wrong.

I reinstalled parallels but fusefs.fs still wasn’t loading. So I typed:

cd /Library/Filesystems
chmod -R 755 fusefs.fs

Reinstalled parallels again, rebooted, and it worked.

I think things are ALMOST back to normal! Jeez. Lesson learned: Don’t freak out if you see “everyone” having “read only” access in sharing system preferences. It refers to linux permissions, not to Mac OS X’s guest file sharing access. Lesson Learned: If you have this bug there is no way to securely share your files in Leopard, and trying to change the permissions for user “Everyone” with get info may hose your system.

Guitar Hero III disconnects during network transmission [solved]

Ever since I bought Guitar Hero III, I haven’t been able to create a match or join a strangers match of any kind. It would always say I have been disconnected from the network during transmission. On strangers match it would disconnect immediately, and on create match I believe it would disconnect when another player attempted to connect. It was horribly disappointing and frustrating.
I could access the leaderboards and create an online profile. Other wii services such as the shop channel and internet channel worked fine.
I found the solution today: I upgraded my wii firmware to 3.1. After that online gaming immediately started working, with no network problems! I’m connected to a match every time and have no problems gaming with anyone (other than people quitting halfway through once they see my leet skills).

Turn off contacts sign on and sign off audio notification in Trillian Basic [solved]

So you’re like me and love Trillian Basic and all the goofy noises it makes. All of them except for the singing on and signing off noises that it makes for all of your contacts. I have all of my coworkers on chat and I’m hearing those noises constantly. When I’m on the phone, my friends ask, “Is that a doorbell?” No…
If you look in Trillian preferences, the only options you have are to turn off sound effects all together or to mute notifications when you’re away. Neither of those are what I’m looking for. I’d turn everything off but I like to have an audio notification when my boss IM’s me.
Well, I found the .wav files of those two notification sounds and just replaced them with silence. You can back yours up and then replace the old ones with these in your program files\trillian\stixe\plugins\Tonal-Sounds\ folder:
contacts-offline.wav
contacts-online.wav
After you’ve replaced the files, restart Trillian. No more annoying doorbell.