HI
I am using expect to transfer the file from unix system to windows server.
however it is not taking the password.
same I tried without script also but still it is not accepting the password.
when I tried with winscp tool it accepting the password.
I am not sure where I am doing wrong
#!/usr/bin/expect
spawn sftp root@xx.xx.xx.xx
expect "password:"
send "abcd1234\n"
expect "sftp>"
send "cd /tmp \r"
expect "sftp>"
send "mput t.txt \r"
expect "sftp>"
send "quit \r"
above script working file when tried unit to unix server
Why are you using:
send "abcd1234\n"
when sending the password (which does not work) instead of using:
send "cd /tmp \r"
when sending data for the other responses (which does work)?
Note also that you have an unneeded <space> that you are sending before the <carriage-return> character ni your last three send
s. The <space> at the end of the cd
, mput
, and quit
commands won't hurt you, but you certainly can't insert an extraneous <space> when sending your password.
Hi Don,
even if I use below command, password is not accepting
sftp root@xx.xx.xx.xx
but same password is working fine when I am using winscp tool Gui to transfer the file
I didn't say anything about changing:
spawn sftp root@xx.xx.xx.xx
in your script to:
sftp root@xx.xx.xx.xx
I suggested changing:
send "abcd1234\n"
in your script to:
send "abcd1234\r"
And noted that you could also change:
send "cd /tmp \r"
expect "sftp>"
send "mput t.txt \r"
expect "sftp>"
send "quit \r"
in your script to:
send "cd /tmp\r"
expect "sftp>"
send "mput t.txt\r"
expect "sftp>"
send "quit\r"
Hi Don,
ok I got it.
here my concern is why password is accepting when trying with unix server but same working fine when using sftp tool GUI