Trying to write an Expect script to login to ~2000 MikroTik Routers for a one time task.
The CLI Prompt is "[admin@RouterOS]", but Expect is returning "^[[?62;c^[[45;3R" which I suspect is ASCII code for what expect misinterpretting because of the brackets. It takes about 5 seconds for expect to display the prompt properly, but when I SSH in manually, the prompt comes up immediately. Also, after the script runs, I have 62;c;3R on the bash prompt after the script quits.
#!/usr/bin/expect
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
spawn ssh -o StrictHostKeyChecking=no admin@192.168.56.101
exp_send "\r"
sleep .25
#expect "admin@192.168.56.101's password:"
exp_send "password"
exp_send "\r"
sleep .5
expect ">"
exp_send "system resource print"
exp_send "\r"
expect ">"
exp_send "quit"
exp_send "\r"
exp_send "\r"
expect eof