unix - Expect script not working -


below script trying login new server:

#!/usr/bin/expect  spawn ssh root@new_server  expect {  "*(yes/no)?" {send "yes\r"}  "*?assword:" {send "9a9c704a2fb0f9c9\r"}  "*current*" {send "9a9c704a2fb0f9c9\r"}  "enter*" {send "jan2016\r"}  "retype*" {send "jan2016\r"}  } 

but exiting this:

**mayankp@mayankp:~/scripts/new$** ./connect-to-server.sh_1  spawn ssh root@new_server  authenticity of host 'new_server (new_server)' can't established.  ecdsa key fingerprint f4:5d:54:14:6c:e3:88:b5:eb:1f:39:bd:34:f6:64:9d.  sure want continue connecting (yes/no)? mayankp@mayankp:~/scripts/new$ 

can let me know going wrong?

you missing exp_continue, make expect run again.

!/usr/bin/expect  spawn ssh root@new_server  expect {      "*(yes/no)?" {send "yes\r";exp_continue}      "*?assword:" {send "9a9c704a2fb0f9c9\r";exp_continue}      "current" {send "9a9c704a2fb0f9c9\r";exp_continue}      "enter*" {send "jan2016\r";exp_continue}      "retype*" {send "jan2016\r";exp_continue}      "\\\$"  { puts "matched prompt"}  } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -