Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ...
- e_file="/tmp/tmpemail.$(date +%s).txt"
- file1='/usr/local/filename1'
- file2='/usr/local/filename2'
- relayserver='relay-server.example.com'
- #ftp info
- FTP_USER='ftpuser' #not the actual FTP User Name
- FTP_DEST_PATH='/'
- ...
- echo -e "Starting Tunnel and SFTP Process"
- # make ssh tunnel for access to SFTP Site
- ssh -L 9022:ftp.example.com:22 serviceaccount@$relay_server -Nf >/dev/null 2&>1
- proc=`ps -ef | grep "ssh -L 9022:ftp.example.com:22" | awk '{print $2}'`
- #checks to see if the tunnel opened correctly then proceeds to push to FTP Site
- if [ "${proc}" != "" ]; then
- #looking for first monday, was thinking of first day but the crontab only runs on monday to friday
- ifStart=`date '+%d'`
- if [ $ifStart == 01 ]; then
- echo -e "File 1 & File2 sent to FTP Site" >> $e_file
- $SFTP_CMD -oPort=9022 -b /dev/stdin $FTP_USER@localhost << END
- cd $FTP_DEST_PATH
- put $file1
- put $file2
- bye
- END
- else
- echo -e "file 2 sent to FTP" >> $e_file
- $SFTP_CMD -oPort=9022 -b /dev/stdin $FTP_USER@localhost << END
- cd $FTP_DEST_PATH
- put $file2
- bye
- END
- fi
- echo "killing ssh tunnel - $proc"
- kill $proc
- else
- ...
- we=$(date +%A)
- dm=$(date +%d)
- if [ "$we" = "Monday" ] && [ "$dm" -lt 8 ]
- then
- .....
- fi
- if [[ $(date +%d) =~ 0[1-7] ]]; then
- : run script
- fi
- if [[ $(date +%w%d) =~ 10[1-7] ]]; then
- : run script
- fi
Add Comment
Please, Sign In to add comment