A friend asked me for a way to put his current public IP address (which changes regularly, it seems) on the clipboard via a keyboard shortcut, and to alert him as to what value was copied. Using a combination of a shell script, Butler, and Growl (specifically, the shell command growlnotify), I was able to put together a solution for him. Note that Butler (disclaimer: I'm part of Many Tricks, Butler's developers) can be replaced by any program that lets you execute shell scripts via a hot key. You could also put the shell script in Automator, and go that route ... but I digress.
Here's the script:
#!/bin/bash MYIP=`curl -s 'http://checkip.dyndns.org' | sed 's/.*Current IP Address: \([0-9\.\.]*\).*/\1/g'` echo $MYIP | pbcopy /usr/local/bin/growlnotify 'IP address copied' -m "Address was: $MYIP"
do shell script /path/to/copyipIn the Triggers tab, I assigned a keyboard shortcut, and I was done. My friend can now have his public IP placed on the clipboard with a simple keyboard shortcut, and get a visual confirmation that it was done correctly. Note that there's no error handling of any sort in my script; if it fails, it's going to fail ugly. You have been warned.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20110113070834584