0

I have fairly simple sh script that checks if process is running, if not then start it. My problem is that sh script cant start the program for some reason...

Here's my script:

#!/bin/sh
if ps x |grep -v grep |grep -c CCcam >/dev/null
then
echo “cccam… ok”
else
echo “cccam… restarting”
/emu/cccam/CCcam.x86 &
fi

Now i run script manually to see if it works

root@lenovo:/emu/cccam# /emu/script/cccam_check.sh
▒cccam▒ restarting▒

It seems that script sees that cccam is not running, then tries to start it, but fails...

root@lenovo:/emu/cccam# ps x |grep -v grep |grep -c CCcam 
0

If i start proccess manually then it starts just fine

root@lenovo:/emu/cccam# ./CCcam.x86 &
[1] 32712
root@lenovo:/emu/cccam#

Anybody have any ideas?

5
  • Do you get an error message when the script fails to start? that should indicate the issue. Nov 20, 2014 at 16:17
  • I get no error whatsoever. Nov 20, 2014 at 16:22
  • Does it work if you enter bash /emu/script/cccam_check.sh ? Nov 20, 2014 at 16:25
  • BTW, you should replace the curly quotes and ellipsis characters with normal quotes and periods, to prevent those splotches.
    – Barmar
    Nov 20, 2014 at 17:06
  • When you start it manually, does it actually stay running in the background, or has it not in fact exited?
    – EricM
    Nov 20, 2014 at 17:52

1 Answer 1

0

try this:

#!/bin/sh
if ps x |grep -v grep |grep -c CCcam >/dev/null
then
   echo “cccam… ok”
else
   echo “cccam… restarting”
   cd /emu/cccam/
   restart="./CCcam.x86"
   $restart &
fi
1
  • Why would this be better than the OP's solution? fully qualifying like the OP did is better practice than "assuming" your cd worked. The only reason I see why this might work is if the CCcam app is depending on something else and uses relative paths.
    – Bram
    Nov 21, 2014 at 17:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .