script 1
#!/usr/local/bin/expect
spawn sftp user@10.xx.xxx.xx
expect \"password\"
send \"pass\r\"
interact
send \"lls\r\"
script 2
#!/bin/bash
expect -c "
spawn sftp user@10.xx.xxx.xx
expect \"password\"
send \"pass\r\"
interact
send \"lls\r\"
"
I have installed TCL/TK,expect.
script1 stops at password prompt itself.
script2 stops after successful login like
spawn sftp user@10.xx.xxx.xx
user@10.xx.xxx.xx's password:
Connected to 10.xx.xxx.xx.
sftp>
My next commands(say i have lcd /home/usr/tmp ,mget *.* )
to transfer the files are not getting executed as part of it.
After
interacthas been called, the control is returned from the script to the user, so that you can type commands manually. Thus, any other command will not be called automatically.Instead executing
interactyou should add anotherexpectstatement waiting for the sftp prompt (sftp>) and issue your desired command afterwards.