Hi,
I have a small script and am having problem at one point. The script runs another script called Run_SQL.sh. All I am trying to do is if the return code from the script is not zero(0) then display some message(which is working fine) and if the return code is zero then run the SED command and run the print command below it.(see in RED BOLD below). My SED command executes fine but the print command sometime works and sometime does not work. Its sporadic. I know there is something very simple but am not able to figure out.
Any advice will be appreciated.
SQLDIR=$t_path
SQLLISTFILE=${t_path}/$SQLFILE
for SQLNAME in `cat $SQLLISTFILE`
do
SQLFILENAME=${SQLDIR}/${SQLNAME}
print "Running ${SQLNAME}"
Run_SQL.sh -f $SQLNAME
if [ $? -ne 0 ]
then
print "There is error in ${SQLNAME}. Check the file."
exit -1
else
var=`head -1 ${SQLLISTFILE}`
if [ "$var" == "$SQLNAME" ] then
sed '1d' ${SQLLISTFILE} | tee ${SQLLISTFILE} > /dev/null 2>&1 --->This command executes fine
print "${SQLNAME} ran sucessfully" --->This is where I am having problems. This command sometime displays and sometime does not displays text.
fi
fi
The command in bold above run sucessfully and sometime it does not show up at all even if the sed command is sucessful. I have to run this print command after the sed command only.
I will really appreciate any advice in this regard.