The ELC Community Blog
A knowledge exchange on Ruby on Rails and Agile Development
Notify me when it's done
by Daniel Lunde on December 21, 2007
Here's a fun little tip I got while working with my client. Occasionally, when we have to run some really long processes (eg. reloading a production snapshot or running some lengthy migration), it's nice to be notified when that process is done.
Quick and dirty notifications
1) For aural feedback simply add " && say 'All Done'"
$ mysql app_dev < dump.sql && say "Finished importing"
2) For growl feedback add " && growlnotify -s -m 'All Done'"
$ mysql app_dev < dump.sql && growlnotify -s -m "Finished importing"* The -s makes the notification stick around until you click it.
* More info about growlnotify below.
Pass or fail notifications
The purpose of && between the two commands is so that the notification will only occur if the first command is successful. You could take that a step more and send different notifications depending on the return status of the command.
$ (cmd && say "Success") || say "Failed" $ (cmd && growlnotify -s -m "Success") || growlnotify -s -m "Failed"* Parenthesis are important.
If you don't care about whether a command succeeds or not, you could just replace && or || with a semicolon.
$ cmd; say "Don't care how it finished, but it did"
Installing growlnotify and a Leopard hack
growlnotify is not installed by default with growl, but it's easy to install.
- Download Growl (http://growl.info/downloads.php) and open the dmg.
- Execute the command: '/Volumes/Growl 1.1.2/Extras/growlnotify/install.sh'.
* The Growl version may be different for you.
If you are using Leopard, there's a bug with growlnotify as of version 1.1.2 that prevents growlnotify from working consistently. However, there's an easy workaround.
- Open up the Growl preference pane and select the Network tab.
- Click to enable "Listen for incoming notifications".
- Now when you run growlnotify, add the "-H localhost" option.
$ cmd && growlnotify -s -H localhost -m "Success"
A bit messy, but it works every time.
Timeline
- Refreshing Rails Generated Views
- Environment Scripts in merb
- Script Terminal with TermInit
- Patching Rails - Rendering form partials
- Open Social plugin progress report
- Notify me when it's done
- OpenSocial on Rails, finally 1.0
- Testing without the database
- acts_as_chattable: make web chatting easy
- OpenSocial Container 0.3.0
- OpenSocial Container 0.2.0
Comments
You can also use Quicksilver: