The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
problems installing expect utilty vikas027 Shell Programming and Scripting 5 07-06-2009 03:56 PM
input from a file into an expect script ? starsky Shell Programming and Scripting 2 04-16-2008 12:38 PM
File as input for a script innocentspirit Shell Programming and Scripting 5 10-26-2007 01:03 AM
suppress echo while reading input in expect sudhir_onweb Shell Programming and Scripting 1 07-23-2007 10:54 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-29-2008
meberline meberline is offline
Registered User
  
 

Join Date: May 2008
Location: St. Louis, MO
Posts: 2
Expect script with file input problems

Hello,
I am trying to write an expect script that will ssh into a large number of Cisco routers and add some commands via the cli. The script I wrote works great for one host however I have over 350 routers that this needs to be added to. The problem is I cannot get the script to read the file of hosts. Below is the shell script and the expect script. The host file is called host_list. Any suggestions would be very much appreciated as I am about to pull my hair out. Thanks.

[~]$ cat pan_hosts
#!/usr/local/bin/bash
cat ./host_list | while read hosts; do
./pan $LINE
done

--------

[~]$ cat pan
#!/usr/local/bin/expect
set host [lindex $argv 0]
spawn ssh -l root $host
set timeout 7
expect "assword: $"
send "xxxxxxxxx\n"
expect "#"
send "config t\n"
expect "onfig)#"
send "ntp server 10.10.1.89 prefer\n"
expect "onfig)#"
send "ntp source vlan 1\n"
expect "onfig)#"
send "clock timezone CST -6\n"
expect "onfig)#"
send "clock summer-time CDT recurring\n"
expect "onfig)#"
send "access-list 88 permit 65.242.29.0 0.0.0.255\n"
expect "onfig)#"
send "access-list 88 permit 24.182.133.64 0.0.0.7\n"
expect "onfig)#"
send "snmp-server community xxxxxxxxxxxxxxxxxx rw 88\n"
expect "onfig)#"
send "exit\n"
expect "#"
send "wr\n"
expect "#"
send "exit\n"
  #2 (permalink)  
Old 05-29-2008
meberline meberline is offline
Registered User
  
 

Join Date: May 2008
Location: St. Louis, MO
Posts: 2
Got it working

I was able to figure out what the issue was even with my 2nd grade expect education.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:39 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0