Ste*_*ano 1 ant bash while-loop
我的最后一个问题取得了如此成功,我决定再试一次.下面的bash循环设置为遍历文件并一遍又一遍地向ant发送消息,直到它遍历文件末尾.当我更改运行ant的命令以简单地回显命令(用于测试)时,它运行正常.当我删除"echo"和命令周围的引号时,它只运行一次脚本并优雅地退出循环.对我来说这似乎很明显,这与ant和退出状态有关,但我不明白为什么会让它退出循环而不是返回.顺便说一句,它总是返回零.
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
Run Code Online (Sandbox Code Playgroud)
干杯,
斯特凡诺