Update
Here are answers to questions in the comments below..
This screenshot shows me running both scripts. Each time the minisatip process was running and the enigma2 process was not running.
The path of the first script, the one with just 3 or 4 lines, is /home/root/test.sh and I can run it from anywhere, it seems, simply like this # test.sh
The path of the second script is /usr/bin/enigma2.sh and as you can see I run it simply like enigma2.sh
As suggested I updated both scripts to remove the wc and awk from the piped command whose output is meant to assign a value to the variable: ENIGMA_PID
I changed /home/root/test.sh to this:
#!/bin/sh
ENIGMA_PID=$(ps ax|grep enigma2|grep -v grep)
echo $ENIGMA_PID
echo "$ENIGMA_PID"
And in /usr/bin/enigma2.sh I added these lines to the top of the script...
#!/bin/sh
ENIGMA_PID=$(ps ax|grep enigma2|grep -v grep)
echo $ENIGMA_PID
echo "$ENIGMA_PID"
# Check if the no_enigma file exists
...
....
Now I ran the scripts and this screenshot shows the output..
The process I am checking for is a binary with path: /usr/bin/enigma2. This binary is not running. Yet, when the enigma2.sh script runs there are two process ids. Is this because the script itself is called enigma2? Well then why are their two process ids called enigma2 and not one?
Question
What do I need to change in this command
ENIGMA_PID=$(ps ax|grep enigma2|grep -v grep|wc -l | awk '{print $1}')
... when it's in a script called /usr/bin/enigma2.sh
... so it doesn't count the script, it is a part of, as a running process?
... the result should be ZERO if the binary /usr/bin/enigma2 is not running.
Thank you!
Flex

