I'm trying to use if-condition in my shell script and have been facing the following issue:
status=$echo ps -ef | grep mysql | cut -c10-15 #--> It produces process-id (for e.g. 012345), if exits, or else returns null
echo $status #--> This prints the process id correctly (for e.g. 012345), but it doesn't take value in if condition
if [ -z "$status" ] #--> it should not be NULL as the variable here is 012345
then
echo "Need to start server"
else
echo "Server already up and running"
fi
Prints first case even if the "status" variable not NULL.