I had such success with my last question, I decided I’d try again. The bash loop below is setup to iterate through a file and send messages to ant over and over again until it runs through the end of the file. When I change the command that runs ant to simply echo the command (for testing) it runs fine. When I remove “echo” and the quotes around the command, it only runs through the script once and exits the loop gracefully. It would seem obvious to me that this has something to do with ant and perhaps an exit status, but I don’t see why that would make it exit the loop instead of returning. It always returns zero, by the way.
echo "Looping through database results and sending to ant..."
# This while loop runs through pendingtxs.result and funnels them to ant
while IFS=, read txid courseid instructorid
do
echo "Beginning substitution of $1 into file..."
sed -e "s/XXXXXXXXXX/$txid/" -e "s/YYYYYYYYYY/$courseid/" -e "s/ZZZZZZZZZZ/$instructorid/" createcourse_notif.template.xml >temp.xml
echo "Substitution complete."
echo "Sending the temp.xml to ant..."
/xncpkgs/ant/bin/ant sendMessage -Dsend.destination=SmsQueue -Dmessage.file=temp.xml
antReturnCode=$?
echo "ANT: Return code is: \""$antReturnCode"\""
echo "Ant is done"
echo "Adding the xml to log.txt for later analysis"
cat temp.xml >> log.txt
echo "Removing temp.xml"
rm temp.xml
echo "Submission of $txid complete."
done < pendingtxs.result
Cheers,
Stefano
ant is probably consuming stdin. Try running
ant … < /dev/null