<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
&gt; So again, the logic for the script is &quot;If it&#39;s it running, killall<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
mythfrontend.real (so Mythbuntu then restarts it) and if it&#39;s not<br>
running at all start it.&quot; but I don&#39;t know how to write bash.<br>
</blockquote>
<br></div>
Hi;<br>
<br>
Run this with the FE running and not running. If the output<br>
matches what you expect, replace the echos with your restart<br>
and start-up commands.<br>
<br>
#!/bin/sh<br>
<br>
pgrep mythfrontend.real 2&gt;&amp;1 &gt; /dev/null<br>
<br>
if [ $? -eq 0 ]; then<br>
    echo &quot;Already running, put restart command here.&quot;<br>
else<br>
    echo &quot;Not running, put your start-up command here&quot;<br>
fi</blockquote><div><div><br></div><div>This should work for the entire thing, just create the necessary rcexec entry with this command, no script necessary (untested in rcexec):</div><div><br></div><div>   pidof mythfrontend.real &amp;&amp; killall mythfrontend.real || <span style="background-color:rgb(255,255,255);color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px">mythfrontend &amp;</span></div>

<div><br></div><div>I know it looks weird, but it really does work.</div></div><div><br></div><div>Boolean logic doesn&#39;t process any more than it has to in Bash... so in an AND... if the left is false, then it doesn&#39;t check the right; in an OR, if the left is true it doesn&#39;t check the right.</div>

<div><br></div><div>And Bash lets you use application exit codes as the values you your logic.  So this basically replicates and if then else structure in one line.</div></div>