Loop Expect statement
Hello everyone
I have the below expect statement:
#!/usr/bin/expect
spawn ssh user@192.168.0.1
expect "user@192.168.0.1's password:"
send "passwd\r"
expect ">"
send "en\r"
expect "Password:"
send "passwd\r"
expect "#"
send "conf t\r"
expect "#(config)"
send "wr m\r"
expect "#(config)"
what i would like to do is run this on over 200 devices. I have a txt file that has all the IPs (separated by carriage returns) . Im thinking the best thing that i need to do is create a for loop or while loop until the end of file.
Can someone please help me create a loop. I also need to know how to import ips from the txt file.
Thank you very much!
|