Create a phone home script to track your Mac

Jan 27, '02 10:30:27AM

Contributed by: bhines

Recently an iMac was recovered using Timbuktu and AppleScript.
The same can be done on OSX easily using this shell script in a cron task or startup item:

#!/bin/sh

cat <<EOF | mail -s "G4 Status: `/bin/date`" your_email@abc.com

NETWORK SETUP
`/sbin/ifconfig -a 2>&1`

PROCESS LISTING
`ps axw 2>&1`

TRACEROUTE TO HOME
`/usr/sbin/traceroute -q1 1.2.3.4 2>&1`
EOF
(Replace 'your_email@abc.com' with your real email address and '1.2.3.4' with your home IP number).

You will need to enable sendmail which this tip sort of explains how to do. I set my script up to email me daily at 6:30PM using the system crontab via the cron GUI frontend Cronnix, and I will also put it in a startup item (I'd not suggest a login item).

I'd suggest using a throwaway web-based free-email address, so you will be able to easily access it if you lose your mac. You can cc to multiple addresses using the -c option to mail.

Credit to ink at MacNN for the idea. :)

Comments (11)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20020127103027197