LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Loop Expect statement (https://www.linuxquestions.org/questions/linux-newbie-8/loop-expect-statement-4175427149/)

dnoy 09-13-2012 07:46 PM

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!

dnoy 09-13-2012 07:56 PM

this was answered in another post and can be closed.


All times are GMT -5. The time now is 05:24 PM.