The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 01-18-2008
chris1234 chris1234 is offline
Registered User
 

Join Date: Apr 2006
Posts: 74
Question on SCP and Mail command

Hey Guys,

I created a script where i am trying to do scp from one machine to another and then from another to another remote machine. I am having a log file also with the current date and time stamp in which i have been successful. I would like to delete the log files older than 30 days in which i have been successful also. My only problem is that how can i write an if statement if any one of the scp fails?

Meaning if my first scp fails then store a message in a log file that scp failed and send an email to appropriate person. same thing goes for second scp also. Anyone can help me out ?

Code:
EXIT_STATUS="?"
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>$LOCAL_LOG_FILE 2>&1
scp -p recon:/az/web/vendornet.abc.com/docs/tester/mike/priceops/*.txt audi:/az/web/ezap.abc.com/docs
# if['$EXIT_STATUS != 0']
echo "File copied Successfully `date +%n%m/%d/%Y%n%H:%M:%S`" >>$LOCAL_LOG_FILE
find /home/test/bin -name 'category_[0-9][0-9]*.log' -atime +30 -exec 'rm' { } \;

Last edited by chris1234; 01-18-2008 at 08:50 AM..
Reply With Quote
Remove advertisements
!!
Forum Sponsor