Hi Jowsaki
Here is one way to do it. I am going to build this up step by step...
I assume that when you run your script, it gives you something you can look for. Eg. the text "... is running" (or the alternative "... is not running") or something similar.
If so, you can pipe the output of your first script through grep to look for your specific text.
We could use this directly with the "-z" option of
test in a script. -z will test if you are testing against a zero length
string:
Note the spaces after the test start indicator ([) and before the end indicator (]). Also the backwards quotation mark "`" around the command that I am running.
Personally I dont like the test for zero length strings. A slight variation would be to tell grep to return a count of how many times it found the "is running string":
You can now use the -eq, -ne, -gt, -lt operators (equal, not equal, greater than, and less than) in your tests:
Some final notes:
I used a relative path name in my examples (./myScriptCheck). For an automated script,
you should always use a fully qualified path name (/home/andrewm/myScriptCheck). Do not assume that the script you are running is in your path - the path may change. It is also a security risk.
Regards, Andrew