We have SFTP Password as ?AFR'-rx]p[HL5G;'&ZM
I am using the script as follows and getting error message as "password: Permission denied, please try again."
The same is working good with command line , Please help how to handle password in expect here.
echo "begin"
port="22"
host_name="test.com"
sftp_username='user1'
sftp_password="?AFR'-rx]p[HL5G;'&ZM"
SOURCE_PATH='data'
DEST_PATH='out'
FILE_NAME='Export.csv'
echo "sftp connection begin"
/usr/bin/expect <<EOF
spawn sftp -C -oPort=$port $sftp_username@$host_name
expect "password:"
expect {
"yes/no" {
send "yes\r";
exp_continue
}
"password"
}
send {$sftp_password\r}
expect "sftp>"
send "mget ${SOURCE_PATH}/${FILE_NAME} ${DEST_PATH}/${FILE_NAME}\r"
expect "sftp>"
send "quit\r"
EOF
echo "Above file(s) transferred from SFTP to Oracle Server"
echo "ftp connection end"
echo "end"
I am using the script as follows and getting error message as "password: Permission denied, please try again."
The same is working good with command line , Please help how to handle password in expect here.
echo "begin"
port="22"
host_name="test.com"
sftp_username='user1'
sftp_password="?AFR'-rx]p[HL5G;'&ZM"
SOURCE_PATH='data'
DEST_PATH='out'
FILE_NAME='Export.csv'
echo "sftp connection begin"
/usr/bin/expect <<EOF
spawn sftp -C -oPort=$port $sftp_username@$host_name
expect "password:"
expect {
"yes/no" {
send "yes\r";
exp_continue
}
"password"
}
send {$sftp_password\r}
expect "sftp>"
send "mget ${SOURCE_PATH}/${FILE_NAME} ${DEST_PATH}/${FILE_NAME}\r"
expect "sftp>"
send "quit\r"
EOF
echo "Above file(s) transferred from SFTP to Oracle Server"
echo "ftp connection end"
echo "end"