Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- USERNAME=amla
- HOST="xx.xx.xx.xx"
- PASSWORD="Axxxxxx_00001"
- sshpass -p $PASSWORD sftp -o StrictHostKeyChecking=no $USERNAME@$HOST <<'EOF'
- for LOCATIONS in ./*/ ; do
- cd "$LOCATIONS"
- array=`find -amin -120 -name "*.flg"`
- if [ ${#array[@]} -eq 0 ]; then
- exit 0
- fi
- for i in ${array[@]}; do
- filexml=`echo $i | sed 's/(.*.)flg/1xml/'`
- filecsv=`echo $i | sed 's/(.*.)flg/1csv/'`
- filetxt=`echo $i | sed 's/(.*.)flg/1txt/'`
- if [ -f "$filexml" ]
- then
- mget -r $filexml /data/mtn/AML/$location
- echo $filexml
- elif [ -f "$filecsv" ]
- then
- mget -r $filecsv /data/mtn/AML/$location
- echo $filecsv
- elif [ -f "$filetxt" ]
- then
- mget -r $filetxt /data/mtn/AML/$location
- echo $filetxt
- else
- echo "No file to copy"
- fi
- done
- #Done for second for
- Connected to xx.xx.xx.xx.
- sftp> for LOCATIONS in ./*/ ; do
- Invalid command.
- sftp> cd "$LOCATIONS"
- Couldn't canonicalize: No such file or directory
- sftp>
- sftp> array=`find -amin -120 -name "*.flg"`
- Invalid command.
- sftp>
- sftp> if [ ${#array[@]} -eq 0 ]; then
- Invalid command.
- sftp> exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement