[lug] More script questions

tpatnoe tpatnoe at peakss.com
Thu Apr 27 16:18:28 MDT 2000


winrip wrote:
> 
>   Is there a way to force a pid to a program?  Or how would one be able to
> assign a pid to a variable at run time so that the pid is known to the script.
> 
> Example of what I'm doing, my program has two pids, and
> 
> ps x|awk '/PROGRAM/ {print $1}'
> 
> adds an extra pid for the awk statement, so I piped "head -2" to the end of the
> statement and get the pids I need.  But, now I need both pids known to the
> script and a test to make sure there are two pids. the conditional test
> shouldn't be any trouble it's just the assigning of pids to variables that
> gets me.
> 
> Any ideas?
> Thanks
> Bill
> 

I don't understand your question completely but $! is the PID of the
last background process (ksh). If you are waiting for a process to
complete you can then do something like this.

while ps -p $pid >/dev/null 2>&1
do
    echo "still running"
    sleep 30
done


-- 
Tory Patnoe                    tpatnoe at peakss.com
Peak Software Solutions        303-734-5031




More information about the LUG mailing list