Quote:
Originally Posted by
chris1234
well if an error occurs on any of the scp i dont want my file successfull command to run and create a log file. That is what i was trying to say so thought to write an if statement and it only executes if the other 2 if statements pass.
Lets use a flags scp1 and scp2
scp1=0
scp2=0
LOCAL_LOG_FILE="category_`date +%m%d%Y`.log"
date +"%m/%d/%Y %H:%M:%S" >$LOCAL_LOG_FILE
scp -p /az/web/ezap.abc.com/docs/*.gif saloo:/az/web/vendornet.abc.com/docs/tester/bkup
if [ $? != 0 ]; then
echo "error occurred"
mailx -s "Subject" "abc@abc.com" <<-EOT
scp failed
`date`
EOT
scp1=1
fi
scp -p recon:/az/web/vendornet.abc.com/docs/tester/mike/priceops/*.txt audi:/az/web/ezap.abc.com/docs
if [ $? != 0 ]; then
echo "error occurred"
mailx -s "Subject" "abc@abc.com" <<-EOT
scp failed
`date`
EOT
scp2=1
fi
if [ scp1 = 0 ]; then
echo "First SCP successful" >> $LOCAL_LOG_FILE
fi
if [ scp2 = 0 ]; then
echo "Second SCP successful" >> $LOCAL_LOG_FILE
fi