LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-13-2012, 07:46 PM   #1
dnoy
Member
 
Registered: Nov 2007
Posts: 69

Rep: Reputation: 15
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!
 
Old 09-13-2012, 07:56 PM   #2
dnoy
Member
 
Registered: Nov 2007
Posts: 69

Original Poster
Rep: Reputation: 15
this was answered in another post and can be closed.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
if statement in a for loop dsmith8890 Programming 6 05-31-2012 01:29 AM
A for loop in an if statement tcsh leavage Programming 2 08-17-2011 11:34 PM
A for loop in an if statement tcsh leavage Programming 2 08-17-2011 11:32 PM
Need help with for loop + if statement Thaidog Programming 5 05-06-2011 09:54 PM
expect statement dnoy Programming 2 04-28-2008 10:21 PM


All times are GMT -5. The time now is 08:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration