I am having issues with an expect script used in a bash script. How it functions is my bash script receives form post data with a list of commands and a list of routers to process the commands on and the lists are sent to variables. The expect script telnets to each router on the list and pushes the commands and it works. My problem is when pushing commands that take a while to receive the output, my expect receives the correct string to exit before all the output is displayed. I am thinking I need a "for" condition on my send "$cmds" but not sure how.
Here is my expect portion:
Here is my expect portion:
Code:
expect << EOF
set timeout 60
log_user 0
spawn telnet ${router}
expect "login: "
send "testusername\r"
expect "Password: "
send "testpass\r"
expect "*#"
send "term len 0\r"
expect "*#"
log_user 1
send "$cmds"
expect "*$router#"
send "exit\r"
EOF