Re: Shell script anomaly
In article <[🔎] 1021429838.3106.9.camel@Gollum>,
Alex Malinovich <demonbane@the-love-shack.net> wrote:
>I'm sure that I might be missing something obvious here, but after a few
>hours I still haven't figured it out. I'm writing a script to detect
>whether xscreensaver is running and activate it if it is. If not, it
>launches the daemon first and then activates. From the command line, the
>following returns the correct exit codes:
>
>if ps -A |grep -q "[x]screensaver"; then xscreensaver-command -activate
>else xscreensaver& xscreensaver-command -activate; fi
>
>However, if I put that exact line into a shell script and run it, the if
>ALWAYS gets evaluated as true. Any ideas?
Sure. If your script is called something like "check-xscreensaver"
the grep finds the script itself.
Why not use "pidof xscreensaver", see man pidof(8)
Mike.
--
"Insanity -- a perfectly rational adjustment to an insane world."
- R.D. Lang
--
To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Reply to: