0

I have set of series SFTP commands which needs to run inside expect.

But when i run the below script due to some reasons am not getting any output. Please correct me if am wrong any where inside the script.

expect << EOF
spawn sftp -oPort=23 -oBatchMode=no -b cmds.txt xxx@1x.2.2x.8x
sleep 3
expect "xxx@1x.2.2x.8x's password:"
send "hello123\r"
EOF

But when i run below command in CLI interface it works super good:

# spawn sftp -oPort=23 -oBatchMode=no -b cmds.txt xxx@1x.2.2x.8x

For Security Reasons, I cant use SCP, SSHPASS, KeyChain Etc.,

1

Once you have told expect to send the password, it has nothing to do so it stops and kills the sftp. Add a wait for end-of-file from the spawned command:

expect eof

You can get more debug from expect by starting it with expect -d.

1
  • Awesome, I have been breaking my head for last 4 days. – Teja R Feb 1 '18 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.