I am writing a simple Linux shell script which checks the status of services running and if any process is not running it will display the name of the process which is not running.
I have tried below and stuck now in else statement. What I want to output an else statement is the name of variable out of the 4 displayed which is having a non zero value.
The output should be like below if RUNWRAPPERSTATUS and EKYCSTATUS are non zero.
There is some while starting RUNWRAPPER AND EKYC . Kindly verify
Actual Code starts here:
ps -aef | grep -i NGEjbClient
RUNWRAPPERSTATUS=$(echo $?)
ps -aef | grep -i startSMS
RUNSTATUS=(echo $?)
ps -aef | grep -i DirectoryService
DISSTATUS=(echo $?)
ps -aef | grep -i EKYCUploadWorkitem
EKYCSTATUS=(echo $?)
if [ $RUNWRAPPERSTATUS -eq 0 ] && [ $RUNSTATUS -eq 0 ] && [ $DISSTATUS -eq 0 ] && [ $EKYCSTATUS -eq 0 ]
then
echo "Jboss Services and App Services started"
var=(echo $?)is an array assignment, maybe you want$(? All$RUNSTATUS$DISSTATUS$EKYCSTATUSwill be equal toecho.