Notify my OS X computer's screen when jobs are done!
October 15, 2005 8:50 AM   Subscribe

How can I use scripting/OS X hacks to notify me in a sweet manner when jobs on remote machines complete?

I frequently run massive ogre-sized jobs in Matlab that can take hours to complete. Unfortunately, the size of the problem isn't consistent from run to run, and I'd like to go off and surf Metafilter without minimizing my productivity in any way. I'm running Matlab from the command-line, and I have access to my underlying shell (tcsh).

So here's the question, is there some awesome way for my computer to notify me (OS X.3) when the terminal is waiting for TTY input? A less useful suggestion would be the ability to generate an email with a single command on the command line (tcsh or python scripts please!) which my email notifier would pick up.

Another sexy idea could involve sending me an IM. The best thing would generate some sort of popup window on my screen, a bell/visual bell could be pretty easily missed.

I love you AskMe.
posted by onalark to Computers & Internet (17 answers total) 1 user marked this as a favorite
 
You might want to check out Growl, which is an OS X application for getting attention, and has a bunch of language bindings, including one for python.
posted by jimfl at 9:14 AM on October 15, 2005


Best answer: Also, you could look at using expect (which comes with OS X) to run your Matlab jobs, and when you are prompted for input, run growlnotify.
posted by jimfl at 9:22 AM on October 15, 2005


Response by poster: Cool, looks like it also has a simple command-line utility. I'm interested in seeing what else is out there and hearing about other types of solutions!
posted by onalark at 9:23 AM on October 15, 2005


The traditional cheap way to do this is just to have the terminal ring the bell a few times:

matlab --run-ogre-sized-job && echo '^G^G^G^G'

where you get the literal ^G characters (which represent ASCII 7, the BEL character) by typing "ctrl-v ctrl-g".
posted by nicwolff at 9:23 AM on October 15, 2005


you can also use python's gensuitemodule.py (in plat-mac) to generate python bindings for just about any applescript-aware app. (is this what growl does?)
posted by dorian at 9:39 AM on October 15, 2005


heh apparently I have not kept up to date enough, gensuitemodule is out of date. appscript is the new goodness.
posted by dorian at 9:41 AM on October 15, 2005


the problem is matlab's shell (in non-java cmdline mode) isn't exactly conforming to things like expect or shell scripting. Even the unix(') command's spawned shell is not useful for a lot of these things. If you can compile your .m with mcc you'll be in a much better position to do fancy things like Growl and sending emails/IMs. That's what I did; it just turns your huge job into a commandline app that you can pass parameters to and put in any script you'd like.
posted by neustile at 9:51 AM on October 15, 2005


Response by poster: neustile, thanks for articulating some of my difficulties a little better than I have. I'm going to take a crack at doing this with Growl. I can't MCC this because its an interactive job that occurs in stages, I actually need to step in and check data structures after individual chunks of the job get completed.
posted by onalark at 9:58 AM on October 15, 2005


Best answer: Mail on the command line:
./your-script; echo "it is done" | mail -s "Subject here" your@address.org
Alternatively, you could use CocoaDialog to pop up a window or create a progress bar (assuming the remote program is piping status information to STDOUT).

The mail solution above would work on the remote machine as well (assuming it can send mail). The CocoaDialog solution would only work locally.

Often if I want to run something remote but have control return to my local computer I will do something like the following:
ssh matthew@remote.host ./some/remote/command; ./some/local/command
For example:
ssh onalark@remote.host ./some/matlab.program; ./some/cocoa-dialog-script
This all assumes, of course, that Matlab will return control to the remote shell after it is done executing. I am sure that can be arranged somehow, but I don't know the details. It may require saving state to a file, then exiting, and then loading state back up later. That'd be doable if the data sets aren't too massive.
posted by mto at 10:00 AM on October 15, 2005


onalark- try
unix('say hello');
right before you need more input in your .m. That works for me in Matlab 7.

The shell will not spawn Applescript enough to show you a dialog (i.e.
unix(['osascript -e ' char(39) 'display dialog ' char(34) 'hello' char(34) char(39)]);
does not work) but perhaps directly talking to Growl and letting Growl handle the UI will work. Also, unix('open -a QuickTime\ Player.app render.mp3') should work.
posted by neustile at 10:35 AM on October 15, 2005


also, if your sendmail is configured to send mail, this should work:
unix(['sendmail -t ' char(34) 'Reply-to:matlab@domain.com\nSubject: job done\nTo: you@domain.com\nContent-type: text/plain\n\nYour job is done!' char(34)]);
Although I gave up matlab for C++/BLAS a year ago the scars remain. It became critical when I found myself maintaining SQL databases and trying to hack real time audio with it.
posted by neustile at 10:43 AM on October 15, 2005


matlab --run-ogre-sized-job; osascript -e 'tell application "Finder" to say "Ogre-sized matlab job done!"'
posted by trevyn at 10:49 AM on October 15, 2005


Oh, remote. Yeah, you can send Applescript commands over the network. Somehow.
posted by trevyn at 10:51 AM on October 15, 2005


Response by poster: I can invoke local commands from the remote machine with ssh. That's not a problem. So you can pretend this is local :).

Everything so far has been usable, but the assumption that I am ON the command line is wrong, I am in Matlab and I can invoke a shell with the system command at appropriate times in the code. This is equivalent to any other programming language/script where you invoke a command from within your code.
posted by onalark at 11:13 AM on October 15, 2005


If you can SSH from the remote machine to the local machine and you can execute Unix commands from Matlab then you're pretty much golden. Any of the above solutions can easily be transformed into what you need.

I highly recommend CocoaDialog because with a little creative footwork you can even have progress bars to show you how far along a task is. And, without any creative footwork, you can get a nice popup easily.

I've used Growl but I eventually abandoned it because it's sort of a shift in your world view which I didn't care to make. However, it'd certainly work as well.
posted by mto at 3:58 PM on October 15, 2005


I often use command line mail to send an email to my cell phone - most wireless providers provide this feature.
posted by neilkod at 8:40 PM on October 15, 2005


Response by poster: (You guys are amazing)
posted by onalark at 10:43 AM on May 1, 2006


« Older "Copy as Text" from Windows Explorer   |   Drop that zero and get with the hero Newer »
This thread is closed to new comments.