[plug] Re: return values

Leon Brooks leon at brooks.fdns.net
Fri Jun 14 10:02:07 WST 2002


On Fri, 14 Jun 2002 06:49, Jon L. Miller wrote:
> I'm not sure I understand what you meant.  I'll give an example:
> I want to be able to check if a process is still running. If it is it
> should return a certain value, if it's not it should return a different
> value. Based those values I can have the script either execute the next
> check or restart the process. Then it needs to log the results either as
> process x running = ok or process has x =stopped.  Then it'll need to
> e-mail me if there is a stopped prcess.  Similar to a crond I guess but
> more information.

By process name:

if [ "$(pidof name_of_process)" = "" ]; then
	echo "process ended"
	echo "process ended" | mail -s help_me jon at miller
else
	echo "at least one copy of process active"
fi

...or by number...

if [ -d /proc/$PID_OF_PROGRAM ]; then
	echo "process active"
else
	echo "process ended"
	echo "process ended" | mail -s help_me jon at miller
fi

There are many other ways of doing each (welcome to unix).

The confusion arises with the misuse of the word `it'. As you used `it', you 
were referring to the running (or not) process, which only emits status when 
`it' ends, and this status can only be `reaped' by the parent of `it'. What 
you are actually asking for is a way to turn the running-or-not state of `it' 
into a status.

Cheers; Leon


Cheers; Leon



More information about the plug mailing list