The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 09-19-2008
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,362
Quote:
Originally Posted by nua7 View Post
Hi All,
I have a master script , which would run 4 scripts in sequence. When the first script gets executed , I need to check if a particular process has been completed. If it is completed , only then proceed with the second script.

This same rule applies to script3 and script4.

Can someone please help me out.This is the function that I wrote for the process check.


Code:
process_check ()
{
p1=`ps -ef | grep o1 |grep -v grep| wc -l`
if [ "$p1" = 0]

You are missing then (as well as a space before ]):


Code:
if [ "$p1" = 0 ]
then

And you don't need two greps as well as wc:


Code:
if ps -ef | grep '[o]1'
then

Quote:
Code:
echo "Process not running"
return 0
else
echo "Process  completed"
return 1
}

Last edited by cfajohnson; 09-19-2008 at 03:49 AM..