Page 1 of 1

See if another process is running

PostPosted: Sat Oct 06, 2012 2:24 pm
by HackerJL
I am using hazel a lot for handbrakecli. Thats great, its working.

I have a rule that runs whenever a file hits the folder with a certain extension. However, I dont want this rule to run if there is already another process running. How can I have it check that a process is running.

I understand I can have it so it passes a shell script, and I see that if it exits with status 0, it indicates a match.

So I run the command:
ps aux | grep HandBrakeCLI | wc -l

which responds with 1, since it finds its own grep command. So I want it to not return that, it should be 0

Further...is that the exit status or just a count. If its the count of 0, that deoesnt satisfy the 'passing' of the shell script.

Any help appreciated.

Re: See if another process is running

PostPosted: Mon Oct 08, 2012 11:22 am
by Mr_Noodle
You need to interpret that output and add your own exit statement with 0 if the output of the ps... stuff is correct to you. Note that what is output is not the exit code. Do "echo $?" immediately after executing a statement if you want to view what the exit code was. I also suggest searching for a shell script tutorial on this stuff.