Password with special character issue when using expect with SFTP

mahesha

New Member
Joined
Sep 19, 2023
Messages
3
Reaction score
0
Credits
42
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"
 


OP
M

mahesha

New Member
Joined
Sep 19, 2023
Messages
3
Reaction score
0
Credits
42
we requested to change password without characters as workaround.
 

Members online

No members online now.

Latest posts

Top