Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
SCP script
Name: stant Date: February 7, 2004 at 17:56:14 Pacific OS: Solaris CPU/Ram: 16 GB
Comment:
Hi,
I need some help to write up a script that searches directory for *.txt files, scp's them to a remote server, puts the files into a bkup directory locally. IF scp has not completed successfully script notifies me via email.
export RSYS REMOTEDIR REMOTEUSER # copy all address files to remote server. for file in `/bin/ls $DIR/address*.txt` do if [ -s "$file" ] then echo "Copying file to $RSYS..." /usr/local/bin/scp $file REMOTEUSER@$RSYS:$REMOTEDIR # backup all address files on local server. /usr/bin/mv "$file" $BKDIR 2> /dev/null; echo $Done." ; fi done /usr/bin/find /usr/files -name 'address*.txt' -mtime +120 -exec rm {} \;
Thanks!
0
Response Number 3
Name: aigles Date: February 10, 2004 at 05:36:19 Pacific
Reply:
echo "Copying file to $RSYS..." /usr/local/bin/scp $file $REMOTEUSER@$RSYS:$REMOTEDIR
if [ $? -eq 0 ] then # backup all address files on local server. /usr/bin/mv "$file" $BKDIR 2> /dev/null; echo "Done." ; else # mail error echo "Failed to copy file $file $RSYS:$REMOTEDIR" | mail -s "$0 - Error" dest_user echo "Error" fi
Jean-Pierre.
0
Response Number 4
Name: stant Date: February 11, 2004 at 17:32:01 Pacific
Summary: Hi. I have a kornshell script that runs on a daily basis as a cron job. Part of what the script does is copy the folder contents from another server to the current server (server where KSH script is r...
Summary: I've got an expect script that is run through cron everynight that is supposed to secure copy a few files from a different server as well as do a few other things. I can't use ssh-agent because I hav...
Summary: Hi All, Thanks in Advance. My requirement is there are some data files to be updated(some times new files get created) regularly in server A, these files are to be updated to the server B(backup serve...