backyard Posted July 7, 2008 Share Posted July 7, 2008 Okay, forgive me I'm bit of a hack. I have a mythtv box running on Fedora and I wrote a script to kill the frontend and to turn off my monitor. I found two separate scripts that each worked independently and I've tried merging the two together but it's not working as planned. The monitor will shut off but the script exits without killing the frontend. The frontend is the GUI that allows you to select what you want to do on myth. The reason I want to kill the frontend on shutoff is so the TV won't still be recording while gone (WAF). I'm posting the original scripts and the merged script. Original: #!/bin/bash PROG=mythfrontend STATUS=`ps -e | grep $PROG | grep -v grep | wc -l | awk '{print $1}'` if [ `echo $DISPLAY | grep -c ":0"` -ge 1 ] then if [ $STATUS -eq 0 ] then ( $PROG -d & ) touch /video/mytharchive/mythtemp/mythpowerbutton-on; else if [ -a /video/mytharchive/mythtemp/mythpowerbutton-off ] then touch /video/mytharchive/mythtemp/mythpowerbutton-on; exit; else touch /video/mytharchive/mythtemp/mythpowerbutton-off; sleep 3; if [ -a /video/mytharchive/mythtemp/mythpowerbutton-on ] then rm -rf /video/mytharchive/mythtemp/mythpowerbutton-o* && killall $PROG fi rm -rf /video/mytharchive/mythtemp/mythpowerbutton-o* fi rm -rf /video/mytharchive/mythtemp/mythpowerbutton-o* fi fi exit 0 Merged: #!/bin/bash PROG=mythfrontend STATUS=`ps -e | grep $PROG | grep -v grep | wc -l | awk '{print $1}'` #frontend running variable STATUS2=`xset -q | grep "Monitor is" | awk '{print $3}'` #screen on variable if [ "${STATUS2}" = "On" ] then xset dpms force off if [ `echo $DISPLAY | grep -c ":0"` -ge 1 ] then if [ $STATUS -eq 0 ] then ( $PROG -d & ) touch /video/mytharchive/mythtemp/mythpowerbutton-on; else if [ -a /video/mytharchive/mythtemp/mythpowerbutton-off ] then touch /video/mytharchive/mythtemp/mythpowerbutton-on; exit; else touch /video/mytharchive/mythtemp/mythpowerbutton-off; sleep 3; if [ -a /video/mytharchive/mythtemp/mythpowerbutton-on ] then rm -rf /video/mytharchive/mythtemp/mythpowerbutton-o* && killall $PROG fi rm -rf /video/mytharchive/mythtemp/mythpowerbutton-o* fi rm -rf /video/mytharchive/mythtemp/mythpowerbutton-o* fi fi else xset dpms force on if [ `echo $DISPLAY | grep -c ":0"` -ge 1 ] then if [ $STATUS -eq 0 ] then ( $PROG -d & ) touch /video/mytharchive/mythtemp/mythpowerbutton-on; else if [ -a /video/mytharchive/mythtemp/mythpowerbutton-off ] then touch /video/mytharchive/mythtemp/mythpowerbutton-on; exit; else touch /video/mytharchive/mythtemp/mythpowerbutton-off; sleep 3; if [ -a /video/mytharchive/mythtemp/mythpowerbutton-on ] then rm -rf /video/mytharchive/mythtemp/mythpowerbutton-o* && killall $PROG fi rm -rf /video/mytharchive/mythtemp/mythpowerbutton-o* fi rm -rf /video/mytharchive/mythtemp/mythpowerbutton-o* fi fi fi exit 0; Can someone tell me what I'm doing wrong? Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 7, 2008 Share Posted July 7, 2008 methinks you're at the wrong website for this. Quote Link to comment Share on other sites More sharing options...
backyard Posted July 7, 2008 Author Share Posted July 7, 2008 I saw some other people posted questions about bash on this forum in "other languages" so I figured I'd give it a shot but I'll look for another forum though. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.