Guest User

Untitled

a guest
May 24th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. #!/bin/bash
  2. ...
  3.  
  4. e_file="/tmp/tmpemail.$(date +%s).txt"
  5. file1='/usr/local/filename1'
  6. file2='/usr/local/filename2'
  7. relayserver='relay-server.example.com'
  8.  
  9. #ftp info
  10. FTP_USER='ftpuser' #not the actual FTP User Name
  11. FTP_DEST_PATH='/'
  12.  
  13. ...
  14.  
  15. echo -e "Starting Tunnel and SFTP Process"
  16. # make ssh tunnel for access to SFTP Site
  17. ssh -L 9022:ftp.example.com:22 serviceaccount@$relay_server -Nf >/dev/null 2&>1
  18. proc=`ps -ef | grep "ssh -L 9022:ftp.example.com:22" | awk '{print $2}'`
  19.  
  20. #checks to see if the tunnel opened correctly then proceeds to push to FTP Site
  21. if [ "${proc}" != "" ]; then
  22.  
  23. #looking for first monday, was thinking of first day but the crontab only runs on monday to friday
  24. ifStart=`date '+%d'`
  25. if [ $ifStart == 01 ]; then
  26.  
  27. echo -e "File 1 & File2 sent to FTP Site" >> $e_file
  28. $SFTP_CMD -oPort=9022 -b /dev/stdin $FTP_USER@localhost << END
  29. cd $FTP_DEST_PATH
  30. put $file1
  31. put $file2
  32. bye
  33. END
  34.  
  35. else
  36.  
  37. echo -e "file 2 sent to FTP" >> $e_file
  38. $SFTP_CMD -oPort=9022 -b /dev/stdin $FTP_USER@localhost << END
  39. cd $FTP_DEST_PATH
  40. put $file2
  41. bye
  42. END
  43.  
  44. fi
  45.  
  46. echo "killing ssh tunnel - $proc"
  47. kill $proc
  48.  
  49. else
  50.  
  51. ...
  52.  
  53. we=$(date +%A)
  54.  
  55. dm=$(date +%d)
  56.  
  57. if [ "$we" = "Monday" ] && [ "$dm" -lt 8 ]
  58. then
  59. .....
  60. fi
  61.  
  62. if [[ $(date +%d) =~ 0[1-7] ]]; then
  63. : run script
  64. fi
  65.  
  66. if [[ $(date +%w%d) =~ 10[1-7] ]]; then
  67. : run script
  68. fi
Add Comment
Please, Sign In to add comment