View previous topic :: View next topic |
Author |
Message |
RedBeard0531 Guru


Joined: 21 Sep 2002 Posts: 415 Location: maryland
|
Posted: Wed Jun 18, 2003 12:35 am Post subject: A script to notify you of success/failure of a command |
|
|
I named it /bin/try . Put it before the command you want to try, and it will play a sound if it works ($pass), and another if it doesnt ($fail). In its current state it is set to use sounds from gaim, and the enlightened sound daemon, but it is very easy to customise.
Code: | #!/bin/bash
#This is an script that will try a command and play a sound
#indicating whether it worked or failed.
#This is your play command. Uncomment the correct 1.
play=esdplay #for users of esd (media-sound/esound)
#play=artsplay #for users of arts (kde-base/arts)
#play=aplay #for users of alsa (media-sound/alsa-utils)
#play=say #for users of speechd (media-sound/speechd)
#These are the files that get played. I used them from gaim
#because they work nicely, but you can use whatever
pass=/usr/share/sounds/gaim/send.wav
fail=/usr/share/sounds/gaim/redalert.wav
#Use these with speechd. $1 is the command you 'try'ed
#pass="$1 completed successfully"
#fail="$1 was unable to finish"
${@} && ${play} ${pass} || ${play} ${fail}
|
Run the following to test that it works.
I put the following in my .bashrc to use this by defualt in emerge and kernel comilation. The only problem with this is that it plays even with --pretend emerges. I couldnt figguer out how to prevent that, but feel free to post If you know.
Code: |
alias emerge="try emerge -v"
alias make="try make"
|
_________________ OH MY GOD! Kenny just killed Kenny!
That Basterd!
Last edited by RedBeard0531 on Thu Jun 19, 2003 12:35 pm; edited 1 time in total |
|
Back to top |
|
 |
rhodyne n00b


Joined: 25 Oct 2002 Posts: 16 Location: Granger TX
|
Posted: Thu Jun 19, 2003 3:53 am Post subject: |
|
|
Made a few changes and used the speechd info on thread https://forums.gentoo.org/viewtopic.php?t=44542 since I've been playing with it and came up with the following:
Code: | #!/bin/bash
$@
err=$?
cmd=`echo $@ | cut -d " " -f1`
pass="$cmd command completed successfully"
fail="$cmd command failed with error code $err"
if [ "$err" == "0" ]; then
say "$pass"
else
say "$fail"
fi |
I tried prettier structure but it didn't work, this does.
I guess if your really wanted to go hog wild with this you could make a look up list of error codes for each command that you use with it and have it read off the real error message.
It would be interesting to see someone tie this into kernel panic codes and have it tell you when there is a panic and read off the error.  _________________ ./done |
|
Back to top |
|
 |
RedBeard0531 Guru


Joined: 21 Sep 2002 Posts: 415 Location: maryland
|
Posted: Thu Jun 19, 2003 12:40 pm Post subject: |
|
|
I moddified my original script to support speechd. could someone test it for me, as i dont have it on my box.
Are there any other types of output people would be interested in? _________________ OH MY GOD! Kenny just killed Kenny!
That Basterd! |
|
Back to top |
|
 |
Raw Kuts n00b

Joined: 05 Mar 2004 Posts: 15
|
Posted: Mon Nov 01, 2004 4:57 am Post subject: |
|
|
RedBeard, I tried your script with speachd (using the say script from that other thread) and it will only say what command you ran up until it reaches a space. For example, if you do
try emerge firesquid
it will just say "emerge" and not the firesquid part.
Also, would it be possible to get it to say the last line or two that was spit out? So for the same example, it would say
emerge: there are no ebuilds to satisfy "firesquid".
EDIT: oops, just realized the date on this. sorry for reviving a dead thread. |
|
Back to top |
|
 |
|