Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

An advanced script/web solution to track stolen Macs UNIX
I worked in a school district for a few years where we had two break-ins that included thefts of Mac laptops. So I decided to create something that would help track laptops in the event they were stolen. This is of course free, one of its major advantages. It is also hosted by yourself, so it is easy to control. This has run on about 1,500 computers without causing any type of overload on machines or the network, and it does exactly what it is suppose to do. I now use it on all home and family computers because I trust it so well. I have used it for about a half a year and it works on Tiger and Leopard.

Note that this is software, so if the thief erases the hard drive on the computer, this will remove the phoning home capabilities. This does take some tinkering around, so it's fairly advanced. But the end result is very rewarding. This hint is broken up into the following sections -- be sure not to skip anything:
  • What this essentially will do
  • Little bits of info about the script
  • What this assumes
  • Four files you need
  • Creating /etc/.cuploader
  • Creating
  • Creating
  • Installing extra files
  • Server setup
  • What to do when stolen or you want to test
  • How to know the script is running
  • Other ideas
  • Conclusion
Read of for the details on each section...
read more (1,520 words)   Post a comment  •  Comments (42)  
  • Currently 2.13 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (8 votes cast)
[35,825 views]  View Printable Version
Back up a UNIX box (or folder) to a DMG image file UNIX
To back up a local UNIX serving box (ALIX1C motherboard with FreeBSD), I wrote a simple but efficient bash script to save all or part of it in a DMG image disk file. This backup should be used as often as required (launching with cron needs a password-free RSA login). This backup is a differential one, and an exact replication is done assuming the RSA user has sufficient privileges to do so.

Why save in a DMG?
  • To avoid my Mac managing another file system deep tree.
  • To simplify moving the backup.
I'm aware I'm losing Time Machine benefits with such a solution, but the script is very easy to modify to sync to a simple file system local folder. Personnaly, my DMG is placed on my Time Machine disk, to avoid filtering the Apple Backup system.


For security and convenience, I use ssh transfering protocol with a shared RSA key. If you do not know how to set this up, you should look at that kind of search. Both boxes (the remote and the Mac) need rsync binaries. On the Mac, you'll need a DMG that's as large as the remote system to back up to. Its name and its mounted name are supposed to be the same.
read more (206 words)   Post a comment  •  Comments (7)  
  • Currently 1.25 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)
[11,293 views]  View Printable Version
10.5: Install ImageMagick without Fink or MacPorts UNIX
I needed ImageMagick -- especially as a Ruby GEM -- so I had to somehow get gem install rmagick working, as it didn't work out of the box: Leopard doesn't ship with ImageMagick.

If you've ever tried to install ImageMagick without Fink or MacPorts, you'll have a quite good chance to go completely nuts. Especially the interdependencies of libjpeg and ghostscript are insane. I also wanted to keep the install as small as possible, and therefore I decided against installing the whole ghostscript package (but you may do so if you like).

I created a set of commands that you can copy-and-paste into a shell script, which should install ImageMagick flawlessly on your Mac. Please notice that Mac OS X 10.5.4 (or higher), XCode 3.1 (or higher), and X11 is required. You'll find the shell commands on this page; just copy and paste to use.

Afterwards, sudo gem install rmagick works like a charm for me. Hope this helps!

[robg adds: I haven't tested this one. To use it, click the Download button next to the code, then open the downloaded file (using Firefox 3, the file was named Download on my machine) in your favorite pure text editor. Save the resulting file to somewhere on your Unix $PATH, and remember to make it executable (chmod 755 scriptname), and you should be good to go.]
  Post a comment  •  Comments (13)  
  • Currently 2.67 / 5
  You rated: 5 / 5 (9 votes cast)
[31,946 views]  View Printable Version
Install the fish shell UNIX
The fish shell is a modern command-line shell that aims to be more discoverable and less beholden to tradition than other shells like bash and csh. Among its many unique features are on-the-fly syntax highlighting of the command line, as well as tab completion for everything under the sun with descriptions for each possible completion. Unfortunately, this shell does not ship with Mac OS X, so you'll need to do some work to install it.

First, download and install MacPorts. This will provide a Terminal command, port, that you can run to download packages. If you prefer a nice GUI for this, though, I recommend downloading and installing Porticus as well.

If you're using plain old port, type port install fish at the command line. If you're using Porticus (or another MacPorts GUI), search for "fish" in "All Packages" and click the Install toolbar icon.

Because fish requires several large libraries that probably aren't installed yet, and must therefore be downloaded and installed before fish can be used, the installation will take quite a while. Go grab a sandwich and come back in a half hour or so.

Once the install is complete, fish is installed. You can run it from Terminal right now by typing /opt/local/bin/fish, and play around with it for a while to get a feel for it. (Hint: you can change the prompt by redefining the fish_prompt function.)

If you decide you like fish better than bash, you'll probably want to set it as your default shell. The process for doing this is not quite as straightforward as it should be, and might qualify as a hint in its own right. You can change a user's shell by opening the Accounts preference pane and right-clicking on that user's name in the list on the left, then choosing "Advanced Options...". However, if you attempt to set your shell to /opt/local/bin/fish, you will get an error when you launch Terminal claiming that the administrator has set your shell to an illegal value! To get around this, you must also add the line /opt/local/bin/fish to the file /etc/shells, which Mac OS X consults to determine what constitutes a "legal" shell. You will need to enter your password to edit the file.

[kirkmc adds: I haven't tried this.]
  Post a comment  •  Comments (19)  
  • Currently 2.50 / 5
  You rated: 3 / 5 (10 votes cast)
[20,468 views]  View Printable Version
Pass command line arguments to GUI apps by default UNIX
Recently I've been wanting a way to pass command-line arguments to GUI apps by default, in my case a -geometry parameter to to make it start up in something approximating full-screen mode. It turns out there's a very easy way to do this.

As many already know, what appear as applications on OS X are in fact directories, containing the actual executable in their Contents » MacOS subdirectory. To cause this executable to be run with specific arguments, simply rename the existing executable to something else (I've used something like appname-bin) and replace it with a shell script that exec`s the renamed binary with whatever arguments you please (followed by chmod 755 or similar to make the script executable). For example, my script for looks like this:

exec /Applications/ -geometry 177x47 $@

The $@ at the end may or may not really be necessary, but I put it in to be on the safe side -- the OS apparently passes a parameter starting with -psn that I'm guessing is the position at which to place the app's window (remembered from the last time it was run). Emacs doesn't recognize this parameter, but other apps probably do. And as I discovered after a bit of experimentation, you do need to use an absolute path to the binary. I've only tested this on Tiger, but I'd be surprised if it didn't also work on Leopard.
  Post a comment  •  Comments (8)  
  • Currently 3.00 / 5
  You rated: 4 / 5 (11 votes cast)
[23,072 views]  View Printable Version
Sleep Macs via SleepWatcher based on monitor state UNIX
When I use GeekTool, my computer won't go to sleep because my hard drive keeps getting accessed. Since I don't want to let this tool go, I have devised an alternate way to get my Mac to sleep. This remedy uses Bernhard Baehr's SleepWatcher. Now, there has been a hint about using this utility in the past, but it doesn't address a key point: your computer falling asleep when you are using it.

If you are doing a lengthy activity that doesn't involve touching the keyboard or mouse (watching a movie, for instance), your computer should stay awake. SleepWatcher doesn't know that, so in the middle of your movie, your computer falls asleep. The easy way around this is to tell SleepWatcher to sleep only when your monitor is off.
read more (187 words)   Post a comment  •  Comments (5)  
  • Currently 2.13 / 5
  You rated: 4 / 5 (8 votes cast)
[15,822 views]  View Printable Version
Capture command line output directly to a text file UNIX
If you're running a Unix command (inside Terminal or otherwise), and you want to quickly capture the standard output in an editable buffer (for examination or snipping), just add | open -tf after the command.

The output of the command will be placed into a new TextEdit buffer, stored in the /private/tmp folder. For example, to get the output of the command-line version of System Profiler into a text file, just type (in the Terminal window):
system_profiler | open -tf
You can then edit the document, and save it (use File » Save As to pick a save location). This method saves a step over using a redirect (>) and then opening the resulting file.
  Post a comment  •  Comments (19)  
  • Currently 2.22 / 5
  You rated: 4 / 5 (9 votes cast)
[27,348 views]  View Printable Version
Find corrupt fonts using Spotlight in Terminal UNIX
In doing an mdimport -A in Terminal, I noticed a particular attribute called com_apple_ats_font_invalid. Spotlight seems to set this attribute for files in a font folder (e.g. ~/Library/Fonts) that aren't valid font files. Try this is a Terminal window to see if you have any bad fonts:
$ mdfind "com_apple_ats_font_invalid == 1"
You can see this in action if you use the -live switch on the above command. Once the mdfind starts, in another Terminal window, create a bad font:
$ echo "bad font" > ~/Library/Fonts/badfont.ttf
You'll see that the query in the first window now shows one match; remove the file you just created (rm ~/Library/Fonts/badfont.ttf), and the query count will drop to zero. Press Control-C to end the mdfind in the other window.

I'm not sure if this is new for Leopard or whether Tiger has it as well.
  Post a comment  •  Comments (5)  
  • Currently 2.75 / 5
  You rated: 5 / 5 (8 votes cast)
[11,458 views]  View Printable Version
Date calculations with stock and Gnu versions of 'date' UNIX
The stock OS X date command ships with a useful -v command that allows date calculation. For example, to determine the last day of February, you could use the following:
date -v3m -v1d
That's the third month in the first -v, and then less one day in the second -v. man date gives many examples. On the other hand, the Gnu version of date that's available from MacPorts does not support this option. Playing a bit with the --date option for Gnu's date, I came up with:
date --date="march 1 1 day ago"
This results in the same date calculation as in the stock date function. Gnu's date also includes the option of printing rfc-2822 and rfc-3339 dates. The latter can be used for applications like Google that require xls dates:
date --rfc-3339='ns'
2008-07-23 18:28:00.110568000+05:30
The ns means nano-seconds.

Given the different features of the two programs, it might be useful to keep both on your system, with the Gnu version of date being stored as gdate.
  Post a comment  •  Comments (6)  
  • Currently 2.57 / 5
  You rated: 4 / 5 (7 votes cast)
[9,161 views]  View Printable Version
Automatically sync Documents folder to iDisk UNIX
Google searches for Sync iDisk largely show results that say something along the lines of "just edit the iDisk version." For me, iDisk is more about backup than anything else. I don't really have the need to share Documents with other people, and the local Documents folder of my laptop is always authoritative for my data. However, it would be nice to have a synced and restorable copy of my Documents "in the cloud" in the event my laptop fails. rsync works well for this.

My first step was to log into MobileMe, click the Account link, then to click on Storage Settings. Here I dropped my mail storage from 10Gb to 2Gb and ended up with an 18Gb iDisk, perfect for backing up my critical documents. Next, I wrote up a simple shell script to handle the rsync function and to copy the data from my local Documents folder to my iDisk's Documents folder.
read more (331 words)   Post a comment  •  Comments (13)  
  • Currently 3.27 / 5
  You rated: 2 / 5 (15 votes cast)
[76,692 views]  View Printable Version