Shell programing question

2005-09-05 Thread Shachar Shemesh
Hi all, I have a shell programing question. I want to write a test that runs a certain background program if it doesn't already exist. What I want to test is this: If the pid file doesn't exist or The pid file relates to a non-existing process or The process is not what I'm trying to run

Re: Shell programing question

2005-09-05 Thread Alex Shnitman
(readlink /proc/`cat /var/run/pid`/exe | grep -q progname) will return 0 if it's the right program and 1 if it's not. In fact, that's exactly my problem. I want the 0 and 1 to be reversed. If I did: You can add -v to the grep command line, it will reverse its function. Or replace grep -q

Re: Shell programing question

2005-09-05 Thread Shachar Shemesh
Alex Shnitman wrote: You can add -v to the grep command line, it will reverse its function. It may help this particular case, but -v reverses the search criteria, not the overall result. Take a file that has the two lines: 1 2 Doing grep 1 file will result in 0 (found), while doing grep -v 1

Re: Shell programing question

2005-09-05 Thread Nadav Har'El
On Mon, Sep 05, 2005, Shachar Shemesh wrote about Shell programing question: will return 0 if it's the right program and 1 if it's not. In fact, that's exactly my problem. I want the 0 and 1 to be reversed. If I did: Is that your only program - reversing the return code? This is easy, just use

Re: Shell programing question

2005-09-05 Thread Amos Shapira
On 9/5/05, Shachar Shemesh [EMAIL PROTECTED] wrote: Alex Shnitman wrote: You can add -v to the grep command line, it will reverse its function. It may help this particular case, but -v reverses the search criteria, not the overall result. Take a file that has the two lines: 1 2