When I run R scripts I go do something else on a different desktop. If I don't check frequently, I never know when something is finished. Is there a way to invoke a beep (like a system beep) or get R to play a sound or notify growl via some code at the end of my script?
Thanks! That was simple and perfect.
Maiasaura
2010-07-29 18:40:24
Simple and perfect, but useless if you've disabled PC speaker. Though I have no idea how does it run on Windows.
aL3xa
2010-07-29 19:07:20
+2
A:
Or if you're using GNU/Linux distro and have pcspkr module blacklisted (PC speaker was always annoying me), try combining system
with some auditive/visual notification, e.g.
system("aplay -t wav /usr/share/sounds/phone.wav") # for auditive bell (an I mean it literary)
system("zenity --title=\"R script info\" --text=\"Script has finished with zero exit status\" --info") # for GTK dialog
You can check zenity manual if you prefer alert in, say, notification area... But, with system
function, you can do pretty much anything: send an email, run some other script, reboot the machine, sudo rm -rf *.*
, etc. anything... and I mean it.
But this stands only IF you're running GNU/Linux (or UNIX) distribution, otherwise, stick to Windows specific commands, though in that case, I can't give you much info...
aL3xa
2010-07-29 19:05:55
The MacOSX equivalent to this is the `growlnotify` script (packaged with Growl (http://growl.info/): `system("growlnotify -t 'R script info' -m 'Finished!'")`
Michael Dunn
2010-07-30 09:00:32
Sorry Mario but that does not help at all. If I can see the screen then I can most certainly tell when it's done. I don't need to output anything more. I was looking for something audible. Sorry I dinged your answer (can't seem to undo that).
Maiasaura
2010-07-29 22:36:58
Why is this getting downvoted? Look at the `alarm` source and you will see that what it does is just a `cat("\a")` call.
nico
2010-07-30 06:38:42
Well, what do you know... here's a description: _Gives an audible or visual signal to the user._ but it's the same thing as `cat("foo\a")`. Maybe the users have read this as `cat("Hello world!\n")`? Hard to tell...
aL3xa
2010-07-30 11:38:28
Didn't realize alarm() = cat('\a'), thanks for the tip. As a side note one can also do '\a' in C and C++ (which is how I have been using it to notify me of things being done). A second side note, if you are on OS X and do 'System Preferences' > 'Universal Access' > 'Hearing' > enable 'Flash the screen...' your whole screen blinks when 'a' is executed.
Mario Pineda-Krch
2010-07-30 16:46:21
+7
A:
You should have it tweet when it's done: http://www.biometrics.mtu.edu/CRAN/web/packages/twitteR
Ken Williams
2010-07-29 21:55:20
Ken: That is f'ing brilliant! Now I don't even have to hang in the same room. I can go to happy hour and have a beer or few till I see a dm saying code is done! I just tried it out and it works great.
Maiasaura
2010-07-29 22:32:49