Multiple if Statements

Hi All,

I need to check for 3 conditions and if all the 3 are not satified need to say that services are not running....

is the below code correct.

#********** Check to see if Service 1 is still running**************
if [ ser1 -eq 1 ]
   then
       echo "$datetimestamp: Service1 is not running" >> $LogPath"/"$LogName"
      #exit 1
      error_flag1=1
fi
#********** Check to see if Service 2 is still running**************

if [ file2 -eq 1 ]
   then
      echo "$datetimestamp: service2 is not running" >> $LogPath"/"$LogName
     #exit 1
     error_flag2=2
fi
#***********To check whether the service 3 is still running**********

if [ file3 -eq 1 ]
   then
      echo "$datetimestamp: service3 is not running" >> $LogPath"/"$LogName"
    #exit 1
    error_flag3=3
fi
if [[ $error_flag1 -eq 1 && $error_flag2 -eq 2 && $error_flag3 -eq 3 ]]
   then
      echo "Services are not  running"
      exit 1
fi

What's the question?

i wanted know if multiple if's can be handeled in anyother way or what i have written is correct

On a first glimpse it looks correct, but the tests seem as if you want to check a variable and so there is missing some $ in front of variables like ser1 file2 file3 .
Depending on what you need, you could write more compact and since it doesn't do any harm but just echoing a message, why not run it to see if it works?

Hey zaxxon..Thanks for your quick reply...

you are correct i have missed the $....

I modified and it worked....
Thank you