I run a script file through CRON daily which involves running selenium testcases and sending the report as mail. Here is my script: check.sh
#!/bin/sh
set -x
./.bashrc
export CLASSPATH=/home/test/TestAutomation/lib/*:.
cd /home/test/TestAutomation/lib/
/usr/bin/java -jar selenium-server.jar &
cd
javac Api.java
java Api
cd /home/test/TestAutomation/selenium/reports/
cp result.html /home/test/TestReports
sh /home/test/repgen.sh
sleep 30
sh /home/test/masRepgen.sh
This script works fine in cron. In this, sh /home/test/masRepgen.sh this script compiles and executes java file and Send Mail.
I made a small change to the above script as follows.
#!/bin/sh
set -x
./.bashrc
. /home/test/blog/build.txt
cd /home/test/VT/CT/
if [ -e /home/test/VT/CT/CT__$BuildLabel ]; then
echo "Testcases has been run already"
else
export CLASSPATH=/home/test/TestAutomation/lib/*:.
cd /home/test/TestAutomation/lib/
/usr/bin/java -jar selenium-server.jar &
cd
javac Api.java
java Api
cd /home/test/TestAutomation/selenium/reports/
cp result.html /home/test/TestReports
sh /home/test/repgen.sh
sleep 30
fi
sh /home/test/masRepgen.sh
After this change, I'm not receiving mail. ie., sh /home/test/masRepgen.sh doesn't compiling java class. I couldn't identify where the error is.
masRepgen.sh contains this.
cd /home/test/
/home/test/jdk1.7.0_12/bin/javac SendMail.java
/home/test/jdk1.7.0_12/bin/java SendMail "http://172.20.8.50/Regression/CR__$BuildLabel/compareresults_index.html" "http://172.20.8.50/Summary__$BuildLabel/complete_summary.html"
I added this in crontab:
45 02 * * * /bin/sh check.sh >> UI.txt
ifstatement may fail.