Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #!/bin/bash
  2. USERNAME=amla
  3. HOST="xx.xx.xx.xx"
  4. PASSWORD="Axxxxxx_00001"
  5. sshpass -p $PASSWORD sftp -o StrictHostKeyChecking=no $USERNAME@$HOST <<'EOF'
  6. for LOCATIONS in ./*/ ; do
  7. cd "$LOCATIONS"
  8.  
  9. array=`find -amin -120 -name "*.flg"`
  10.  
  11. if [ ${#array[@]} -eq 0 ]; then
  12. exit 0
  13. fi
  14.  
  15. for i in ${array[@]}; do
  16. filexml=`echo $i | sed 's/(.*.)flg/1xml/'`
  17. filecsv=`echo $i | sed 's/(.*.)flg/1csv/'`
  18. filetxt=`echo $i | sed 's/(.*.)flg/1txt/'`
  19. if [ -f "$filexml" ]
  20. then
  21. mget -r $filexml /data/mtn/AML/$location
  22. echo $filexml
  23. elif [ -f "$filecsv" ]
  24. then
  25. mget -r $filecsv /data/mtn/AML/$location
  26. echo $filecsv
  27. elif [ -f "$filetxt" ]
  28. then
  29. mget -r $filetxt /data/mtn/AML/$location
  30. echo $filetxt
  31. else
  32. echo "No file to copy"
  33. fi
  34. done
  35. #Done for second for
  36.  
  37. Connected to xx.xx.xx.xx.
  38. sftp> for LOCATIONS in ./*/ ; do
  39. Invalid command.
  40. sftp> cd "$LOCATIONS"
  41. Couldn't canonicalize: No such file or directory
  42. sftp>
  43. sftp> array=`find -amin -120 -name "*.flg"`
  44. Invalid command.
  45.  
  46. sftp>
  47. sftp> if [ ${#array[@]} -eq 0 ]; then
  48. Invalid command.
  49. sftp> exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement