You are not logged in.
Pages: 1
I am trying to make a simple little script that will check for mythfrontend with pidof and then kill it if the process exists (it rarely but time to time freezes). This is for a Mythbox for the family room and I intend to bind the script execution to a remote button via lirc so it can be done instantly, but it is not working correctly:
#! /bin/bash
if pidof mythfrontend ; then
zenity --notification --text="Mythfrontend process successfully killed :)" && kill -s 9 $1
else
# echo "Mythfrontend not running" &&
exit
fi
I tested and I got this output:
~/scripts/myth > ./kill-frozen-fe
21369
Xlib: extension "Generic Event Extension" missing on display ":0.0".
Xlib: extension "Generic Event Extension" missing on display ":0.0".
Xlib: extension "Generic Event Extension" missing on display ":0.0".
Xlib: extension "Generic Event Extension" missing on display ":0.0".
Xlib: extension "Generic Event Extension" missing on display ":0.0".
Xlib: extension "Generic Event Extension" missing on display ":0.0".
And mythfrontend was not killed. (And I have seen that xlib line before and other scripts/commands have worked fine despite it.)
TIA for any help
Last edited by colbert (2009-03-10 20:15:34)
Offline
the Xlib errors are meaningless but i think they prevent you're kill command because zenity is reporting errors thus && will never execute the kill.
reverse the statement with kill ... && zenety ... 2>/dev/null
that should kill myth, then [if successful] display the message and send the meaningless Xlib errors to the /dev/null abyss.
hope it works.
//github/
Offline
Thanks brisbin33, I have tried the line like this:
kill -s 9 $1 && zenity --notification --text="Mythfrontend process successfully killed :)" 2>/dev/null
But it keeps showing this:
~/scripts/myth > ./kill-frozen-fe
21449
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
~/scripts/myth >
If I take out the zenity line and try this:
kill -s 9 $1 2>/dev/null
Then it shows the process ID with that "kill: usage.." etc. line disappearing to the /dev/null. I think it's the "kill -s 9 $1" part not going right, I tried $2 and $0 but no go. Strange because in my .bashrc I have "k9" alias for "kill -s 9 $1" but here not working
Offline
i'm a little confused... they way i would do it is this:
PID=`pidof mythfrontend`
if [ ! -z "$PID" ]; then
kill -s 9 $PID && zenity ... 2>/dev/null
fi
right?
edit, slight difference... i /think/ [ -e $thing ] is the same as [ ! -z $thing ], but i know this way works.
Last edited by brisbin33 (2009-03-10 20:29:08)
//github/
Offline
$1 after kill should be $(pidof mythfrontend)
Or rather,
#! /bin/bash
pid=$(pidof mythfrontend)
if [ $? = 0 ] ; then
zenity --notification --text="Mythfrontend process successfully killed :)" && kill -s 9 $pid
else
# echo "Mythfrontend not running" &&
exit
fi
And the xlib stuff is just messages and does not do anything to the && statement.
Offline
Thanks very much fellas. Procyon that worked! Brisbin33 I tried that way of your post but it did not kill the process, but gave no errors.
Thanks a lot for the help guys
Offline
Pages: 1