#!/bin/sh
SUCCESS=0
java -jar sbc.jar &
while [ true ];
do
echo "sleeping"
sleep 5
echo "again"
tail -1 ~/NetBeansProjects/xyz/dist/newlog.log | grep -q "[INFO ] - Stream closed"
if [ $? = 1 ]
then
echo " entered if "
java -jar sbc.jar &
else
echo " did not if "
fi
done
I want to use a better variable than $? to store the result of the previous line because I may need it more than once. The script is intended to check the last line of the file newlog.log for a particualr string and then start sbc.jar again because the string confirms that the program has stopped.