Sorry to ask this easy question but I am stuck. In a scenario i am executing one shell script which contains a if - else construct :
if [ $var -eq 0 ]; then
echo $line
$line >> successful_build.txt
else
$line >> failed_services.txt
fi
explaination : if the value of variable is equals to zero , the content of line variable is appended to a file called successful_build.txt else it is to be appended to another file called failed_services.txt.
when I am executiong the script all commands are working properly but shell is showing an message no file or directory exists with this name. It is not able to create the file either of two.
Even if I explicitly create the file it not able to append the data in the file it remains blank. Any guess ? please help. Thanks in advance.
I am storing the execution status of a command in the var variable. The snippet goes like this :
#running ant command
ant -f ../../../build.xml
#storing the ant command execution status
var=`echo $?`
#if ant executes successfully file name stores to success file #or else file name stored into failed file. (line has read from another files assume it workes fine and it contains a file name simply)
if [ $var -eq 0 ]; then
echo $line
echo $line >> successful_build.txt;
echo $?
else
echo $line >> failed_services.txt
fi