adumitrescu
Programmer
I've written a simple expect script to automate an sftp transfer to a remote server (shared keys not an option - must use password). It works great, except for the first time! This is because the local ssh-key file must be created.
Here is the script:
Code:
expect <<EOF
spawn sftp $USER@$HOST
expect "word:"; send "$PASS\r"
expect "sftp>"; send "put $FNAME\r"
expect "sftp>"; send "quit\r"
EOF
The chunk of text that appears the first time is:
The authenticity of host '192.168.1.1 (192.168.1.1)' can't be established.
RSA key fingerprint is 12:34:56:78:90:12:34:56:78:90:12:34:56:78:90:12.
Are you sure you want to continue connecting (yes/no)?
What I would like is the initial expect phrase to look for "(yes/no)?", and if found send the "yes\r". If not found, then timeout to the next phrase (which is the password prompt).
Suggestions welcome. -thanks