[mythtv-users] Scripting help -- check whether mythfrontend is running or not

Daniel Segel mythtv at archer-segel.com
Mon Nov 21 23:03:43 EST 2005


cardboil wrote:
> I'd like to write a little script and attach it to my one of my remote 
> control keys.  However, I only want the commands to execute when 
> mythfrontend is NOT running.  Can someone help me write the IF 
> statement that will check whether mythfrontend is running or not?  
> Thank you!
This will kill mythfrontend if it's running, or start it if it's not:

#!/bin/bash
PROG=mythfrontend
STATUS=`ps -e | grep $PROG | grep -v grep | wc -l | awk '{print $1}'`

if [ $STATUS -eq 0 ]
then
    ( $PROG & )
else
    killall $PROG
fi
exit 0


More information about the mythtv-users mailing list