Using conditional statements inside 'expect'
问题 I need to automate logging into a TELNET session using expect , but I need to take care of multiple passwords for the same username. Here's the flow I need to create: Open TELNET session to an IP Send user-name Send password Wrong password? Send the same user-name again, then a different password Should have successfully logged-in at this point... For what it's worth, here's what I've got so far: #!/usr/bin/expect spawn telnet 192.168.40.100 expect "login:" send "spongebob\r" expect "password