As an owner of two iBooks and a Mac mini, it has struck me that these are all likely targets for a thief. A while ago I recalled this story about how someone used Timbuktu Pro to recover a stolen iMac. I then realised that because we use Apple's Remote Desktop software at work, then all I need is the current IP address of a computer to be able to observe/control it.
So I wrote a perl script to lookup my computer's IP address and email it to me at regular intervals. I then had the idea to make the script determine the location of the computer based on the IP address. This is not always an exact science, but it can often pinpoint the town where the computer is. Recently I also realised that I could use the UNIX screencapture command to also email myself a screen capture (to potentially see what any thief is viewing/typing). This might be of more use to those who don't own Remote Desktop. Finally, my latest source of inspiration occurred after buying an iSight camera for my Mac mini. I discovered the great (and free) isightcapture utility, which now allows me to email pictures taken by the iSight camera.
So I now have my computers send me regular emails throughout the day which get automatically filtered by a rule in my Mail application. Because each of these three different functions (IP address, screen capture, and isight capture) require different tweaks to the system, I wrote three different perl scripts so people can pick and choose what functionality they want. These three scripts can be downloaded as a tarball, or downloaded separately from my blog, which has full and detailed instructions on how to install each script (some require some tweaks to the system).
The main limitations of these scripts are that a) the stolen computers need to be online long enough for the scripts to run, and b) the thief doesn't just wipe your hard drive. I try to counter the second option by not using a password on the screensaver, and setting the computers to automatically log into a somewhat-restricted guest account following any reboot. Hopefully this would encourage someone to use the computer just long enough for you to get some helpful information emailed to you.
The Remote Desktop Client app is a pretty handy way to remotely manage/control a Microsoft Windows workstation. However, the solution Microsoft provided is a little bit outdated and runs on Rosetta, which hogs CPU and memory. An alternative way of doing this is by using the rdesktop program, which is open source for Linux/Unix.
First, go to their download page and download the latest source code. Extract the source to say ~/rdesktop. Then, we need to compile the program on Mac OS X. Open Terminal and cd ~/rdesktop, run the following commands:
$ sudo make install
Finally, you can use X11 to run the rdesktop program.
[robg adds: You'll need to have the X11 application installed in order to compile and use rdesktop. I had some issues initially, due to an X11 install that was somehow messed up (no X11R6 directory in /usr). After some retries with the X11 installer, compiling worked as described above.]
As a Mac OS X administrator and as someone who likes to use shell and perl scripts to automate things, I find myself doing a lot of debugging and logging. To make things simpler, I wrote a perl script which I call from other scripts to output errors, warnings, and info in an ordered, easy-to-read system-log-like format.
Save the script text to a file (logger.pl), open Terminal and change the file mode to allow execution (chmod u+x /path/to/logger.pl), and call the script within (or without) another a script like this:
The process list of Activity Monitor is very nice, but oftentimes I want a lightweight alternative that is easy to start, and has very little impact on system resources. In order to achive this goal, I started with the top command as my basis. In its standard mode, top is still a bit resource hungry, so I added a few options (remove costly traversals of kernel datastructures, update every 10 seconds, sort by resident memory size):
/usr/bin/top -R -F -s 10 -o rsize
For making this command easily usable (either by double-click or by Spotlight opening), I used the Execute this command feature (Execute command in a shell activated) with the exec command at the beginning of the above command line in the Save dialog of Terminal. Together with setting the Close the window option in Window Settings... > Shell, this ensures that very little memory is consumed (the shell is replaced by using exec). The resulting Terminal window containing top can be easiy terminated by just typing q when it is active. Additionally, the scrollback buffer should be disabled in Window Settings... > Buffer.
Saving the resulting file under the name topmem.term makes it possible to either double-click the file, or start it by typing topmem in Spotlight and hitting Command-Return. Additional commands can be built, which sort by different fields (e.g. -o cpu, -o time). I have put a ready-made topmem.term as shown above (with green on black colors and slight background transparency) on my website.
[robg adds: I haven't tried the linked topmem.term file, but the rest works as described.]
The great and free GeekTool (PowerPC | Intel) can write the contents of any file, and the output of any shell command, right onto the desktop. Unfortunately it doesn't support self-updating commands like top, and the official workaround (break the loop with top -lk and set Refresh to keep restarting it) is rather Heisenbuggy:
With k > 1, they become skewed by an overestimated CPU usage for top itself.
Either way, relaunching top every few seconds soon causes pid's to roll over 30000, so that recent processes must be hunted down the list rather than conveniently appearing on top.
In short, watching top this way perturbs it more than we'd like. In this hint, I describe a different (k = 0) workaround which appears to solve the problem, i.e. display top exactly like Terminal does.
Looking through applications in Terminal, I stumbled upon automator, which simply lets you run an existing Automator workflow from the Terminal. This could be useful in Perl, Bash, and other scripting.
[robg adds: The man page for the command is quite brief; it says just this: automator runs the specified workflow document. To create or edit a workflow, use the Automator application. There are no options.]
This hint allows you to randomize your e-mail signatures. I use this with Thunderbird, but this hint should work with any e-mail client that refers to an external file for your signature. I needed a solution that just worked and didn't really require anything more from me. Some of the plug-ins out there require some user action each time you write an e-mail -- which I didn't like. Also, most of my signature remains the same, so I wanted my solution to simply change one part of my signature (a tagline), the rest remains the same.
Basically, my solution is composed of a couple files which can be merged to form a random signature (and any supporting graphic files, etc). These should be placed in your normal directory holding your signature. For this example, let's say this is the directory /Users -> jbloggs -> signature/:
signature-template.html - my normal signature (and all of its support files), but with a minor change: I've replaced the tagline with a marker [TAGLINE].
taglines.txt - this is a list of all my taglines that I want to randomly choose from for each e-mail. There is one tagline per line, and any characters that might be special to the shell must be escaped properly.
Other files required to make up this solution are the following, which are to be placed in the directory /Library -> StartupItems -> SignatureRandomizer, which is owned by root, has its group set to wheel and has permissions 0755 (drwxr-xr-x):
SignatureRandomizer.watchdog - this is the magical bit. This shell script monitors my signature.html file to see if it has been used, and if it has, it creates another one by randomly selecting a line from my taglines.txt file and inserts it into the signature-template.html file.
SignatureRandomizer - this script controls the watchdog-script.
StartupParameters.plist - this is required to automatically start the service when my Mac boots up.
You may not have noticed, but a number of recent Apple updates (eg. at least the 10.4.5 through 10.4.7 updates) have included the SetFile utility in their installer packages, leaving a copy in /Library/Receipts.
To find what is available on your system, try either of these commands (the first may include some unrelated results, but it's faster, assuming you've created the locate database) in Terminal (found in /Applications -> Utilities):
$ locate SetFile | xargs ls -lut
$ find /Library/Receipts -name SetFile | xargs ls -lut
SetFile will be familiar to many users as the handy command line tool for making files and folders visible / invisible (if their visibility isn't already being determined by something else), changing their type or creator codes, setting file creation date, or other functions, as detailed in its man page
So for example, if you have a PowerPC Mac, and the 10.4.7 update was installed with the Delta (not Combo) installer, and you have a folder on your Desktop" called Inviso, it should be possible to hide that folder with this command:
Contents/Resources/SetFile -a V ~/Desktop/Inviso
Quit and restart the Finder (don't Force Quit or Relaunch from the Dock), or log out and back in for the change to take effect. Repeating the procedure, substituting v for V will reverse the change.
Maybe this will let users without the Developer Tools get in on the various MacOSXHints that call for SetFile, or save someone suffering from the appearance of a previously-hidden folder or symbolic link the bandwidth of downloading the entire Developer Tools package (version 2.3 weighs in at 915MB) just to get access to SetFile, which itself is only 41KB for the Universal binary.
I spend a lot of time in Terminal, and a lot of time in GUI applications. There have been a few hints about using the Finder with Terminal, so here's mine to add to the collection.
I created some shortcuts for CodeWarrior and Xcode, as those are the programs I use most with Terminal. The shortcuts execute a cd to change Terminal's active directory to match that of the open CodeWarrior or Xcode document. I did this by creating the following six functions in my .profile file.