I'm a newbie in the linux environment, and I'm starting to create an automated smoke test for several commands we frequently use at our company. Basically, running some kind of shell script that runs through multiple commands and also validates the command's output.
The first test cases I started writing out was to check our service can be successfully stopped and started. After researching around about bash scripts I came up with this:
#!/bin/bash
sudo service companyservice stop | grep 'Stopping companyservice ... [ OK ]' &> /dev/null \
if [ $? == 0 ] then echo "Stopping Company Service: SUCCESS" \
else echo "Stopping Company Service: FAIL. GO HARASS A DEVELOPER" \
fi
sudo service companyservice start | grep 'Starting companyservice ... [ OK ]' &> /dev/null \
if [ $? == 0 ] then echo "Starting Company Service: SUCCESS" \
else echo "Starting Company Service: FAIL. GO HARASS A DEVELOPER" \
fi
I saved this as SmokeTest.sh, but when running sh SmokeTest.sh on command line, I see nothing on the output. No error, no failure, no success. Nothing.
Any help or hints with this is much appreciated. I am using Red Hat 6.6 OS. Also should this be right way to automate on Linux if I want to validate command's outputs?