You are not logged in.
I am trying to write a script that will tell me the status of a program. I just want to know if it is running or not, so there may be an easier way than what I am trying.
if [pgrep lighttpd]; then status="ON"; else status="OFF"; fi
That does not work. I have tried with "pgrep lighttpd' with (pgrep lighttpd) and 'pgrep lighttpd' even `pgrep lighttpd` (back quote) but have not been able to get the correct response.
Can any of you set me straight or am I hopless?
Offline
i would use pidof for that.
if [ "$(pidof lighttpd)" ]
then
status="ON"
else
status="OFF"
fi
untested but should work.
Offline
i would use pidof for that.
if [ "$(pidof lighttpd)" ] then status="ON" else status="OFF" fi
untested but should work.
Works great! Thanks Dai!
I had a kdialog that I wanted to put the status of lighttpd into the title, and this does it.
(I had forgotten about pidof - plus not sure on where to put the brackets/quotes/$ etc. - this helps)
Offline
You are welcome JimW, You could also shorten it to a one-liner with...
[ "$(pidof lighttpd)" ] && status="ON" || status="OFF"
Offline