我有以下代码..
while read copy
do
cp -v $copy | tee -a $LOGFILE
echo $?
if [[ $? -ne 0 ]]
then
echo "Error copying files. Exiting ..." | tee -a $LOGFILE
exit 1
fi
done < copy_new_files.tmp
..如果由于权限被拒绝等错误而无法复制文件,我希望脚本停止。
脚本的输出没有在权限被拒绝错误上产生错误代码..
+ read copy
+ cp -v acts035.fmt /home/test/gp/efin/source/pl/acts035.fmt
cp: cannot create regular file `/home/test/gp/efin/source/pl/acts035.fmt': Permission denied
+ tee -a /home/test/gp/efin/fixes/12345/efin_fix_copy_12345.log
`acts035.fmt' -> `/home/test/gp/efin/source/pl/acts035.fmt'
+ echo 0
0
如果出现错误,如何让脚本暂停?
非常感谢。