Hi All,
I am new to expect, to trying to automate shh login but also like to check the condition,because first time ssh will ask for confirmation to add the public key "yes/no" but next time it won't, Please check my below script and let me know if i am using it in a correct way.
Quote:
#!/usr/bin/expect
#!/bin/sh
message1="Are you sure you want to continue connecting (yes/no)?"
message2="password"
spawn ssh root@192.168.10.3
if [ expect == $message1 ]
then
send "yes\r"
expect "password"
send "redhat\r"
fi
if [ expect == $message2 ]
then
send "redhat\r"
fi
interact
|
Output
Quote:
root@localhost script]# ./copy1.exp
invalid command name "message1="Are"
while executing
"message1="Are you sure you want to continue connecting (yes/no)?""
(file "./copy1.exp" line 4)
|