From: "Zhang, Anchi" To: Subject: clogin -x fails when cisco prompt gets too long Date: Mon, 3 Feb 2003 18:27:19 -0600 Message-ID: <4542F75EC5DC2E44AA0B648E20D00E3504C741@rriexmb10.services.reinternal.com> It seems that clogin -x file will fail if the commands in file result in a long prompt from the device. In the following example, "REP2970_Server(config-router)#" would be expected after "router eigrp 216" was sent. Shortening the hostname would make the script work. log2% cat foo #!/bin/sh echo "conf t router eigrp 216 eigrp log-neighbor-changes end wr mem" >/tmp/$$ clogin -x /tmp/$$ 10.51.2.51 rm /tmp/$$ log2% ./foo 10.51.2.51 spawn ssh -c 3des -x -l azhang 10.51.2.51 azhang@10.51.2.51's password: REP2970_Server2B_L3>enable Password: REP2970_Server2B_L3# REP2970_Server2B_L3#term length 0 REP2970_Server2B_L3#conf t Enter configuration commands, one per line. End with CNTL/Z. REP2970_Server2B_L3(config)#router eigrp 216 Error: TIMEOUT reached log2% From: Andrew Partan To: "Zhang, Anchi" Cc: rancid-discuss@shrubbery.net Subject: Re: clogin -x fails when cisco prompt gets too long Date: Wed, 5 Feb 2003 20:56:08 -0500 Message-ID: <20030206015608.GC27130@partan.com> References: <4542F75EC5DC2E44AA0B648E20D00E3504C741@rriexmb10.services.reinternal.com> In-Reply-To: <4542F75EC5DC2E44AA0B648E20D00E3504C741@rriexmb10.services.reinternal.com> On Mon, Feb 03, 2003 at 06:27:19PM -0600, Zhang, Anchi wrote: > It seems that clogin -x file will fail if the commands in file > result in a long prompt from the device. In the following example, > "REP2970_Server(config-router)#" would be expected after "router > eigrp 216" was sent. Shortening the hostname would make the script > work. $prompt is set to "REP2970_Server2B_L3#" & clogin is looking for this. Once you go into config mode, the prompt changes & $prompt no longer matches. Either write your own expect script & call it via 'clogin -s script', or stick your config comands into a rcp file & use util/cisco-load.exp, or do something like this: clogin -c "conf t\rrouter eigrp 216\reigrp log-neighbor-changes\rend;wr mem" --asp From: Johan Grip To: rancid-discuss@shrubbery.net Subject: RE: rancid hangs due to expect, ssh, or cisco? Date: Fri, 7 Feb 2003 13:13:20 -0000 Message-ID: <59CFF4F7B037D411804800508B6D22B204627E12@UKEDIMAIL02> On Tue, Dec 31, 2002 23:08 Andrew Partan wrote: >On Tue, Dec 31, 2002 at 02:49:48PM -0600, Zhang, Anchi wrote: >> My temporary workaround to this problem is >> >> log2# diff clogin clogin.orig >> 457c457 >> < send "term length 100\r" >> --- >> > send "term length 0\r" > >Well that is whacko. Is 'term length 0' not working on your router? > --asp I have the same problem here. Commands doing a lot of output hangs. If I do clogin -c "wr ter" on a device with a large config clogin hangs. Likewise with "sh cam dyn" on some catalysts as well. I've basically used the same workaround, but also had to add a prompt because one of my Cats changed the more prompt. --SNIP-- --- clogin.in Tue Jul 30 07:14:10 2002 +++ /home/rancid/bin/clogin Fri Feb 7 13:00:40 2003 @@ -452,9 +454,9 @@ # skip if its an extreme. if { [ string compare "extreme" "$platform" ] } { if [ regexp -- ".*> .*enable" "$prompt" ] { - send "set length 0\r" + send "set length 100\r" } else { - send "term length 0\r" + send "term length 100\r" } regsub -all "\[)(]" $prompt {\\&} reprompt # match cisco config mode prompts too, but not for catalyst ie: (enable) @@ -496,6 +498,9 @@ -re "^ --More--\[^\n\r]*" { send " " exp_continue } + -re "^--More--\[^\n\r]*" { + send " " + exp_continue } -re "^<-+ More -+>\[^\n\r]*" { send_user -- "$expect_out(buffer)" send " " @@ -526,6 +531,9 @@ -re "^ --More--\[^\n\r]*" { send " " exp_continue } + -re "^--More--\[^\n\r]*" { + send " " + exp_continue } -re "^<-+ More -+>\[^\n\r]*" { send_user -- "$expect_out(buffer)" send " " --SNIP-- Could probably be solved in a nicer way by adjusting the regexp above it, but I had to fix it somewhat in a rush, and since forgotten about it. Regards, Johan From: john heasley To: Johan Grip Cc: rancid-discuss@shrubbery.net Subject: Re: rancid hangs due to expect, ssh, or cisco? Date: Fri, 7 Feb 2003 10:15:24 -0800 Message-ID: <20030207181524.GQ4847@shrubbery.net> References: <59CFF4F7B037D411804800508B6D22B204627E12@UKEDIMAIL02> Fri, Feb 07, 2003 at 01:13:20PM -0000, Johan Grip: > On Tue, Dec 31, 2002 23:08 Andrew Partan wrote: > >On Tue, Dec 31, 2002 at 02:49:48PM -0600, Zhang, Anchi wrote: > >> My temporary workaround to this problem is > >> > >> log2# diff clogin clogin.orig > >> 457c457 > >> < send "term length 100\r" > >> --- > >> > send "term length 0\r" > > > >Well that is whacko. Is 'term length 0' not working on your router? > > --asp > > I have the same problem here. Commands doing a lot of output hangs. > If I do clogin -c "wr ter" on a device with a large config > clogin hangs. Likewise with "sh cam dyn" on some catalysts as well. > > I've basically used the same workaround, but also had to add a prompt > because one of my Cats changed the more prompt. can you tell me what operating system you are using and what version of expect/tcl? From: Johan Grip To: john heasley Cc: rancid-discuss@shrubbery.net Subject: RE: rancid hangs due to expect, ssh, or cisco? Date: Mon, 10 Feb 2003 07:14:36 -0000 Message-ID: <59CFF4F7B037D411804800508B6D22B204627E1F@UKEDIMAIL02> > On Fri, Feb 07, 2003 19:15 john heasley wrote: > Fri, Feb 07, 2003 at 01:13:20PM -0000, Johan Grip: > > On Tue, Dec 31, 2002 23:08 Andrew Partan wrote: > > >On Tue, Dec 31, 2002 at 02:49:48PM -0600, Zhang, Anchi wrote: > > >> My temporary workaround to this problem is > > >> > > >> log2# diff clogin clogin.orig > > >> 457c457 > > >> < send "term length 100\r" > > >> --- > > >> > send "term length 0\r" > > > > > >Well that is whacko. Is 'term length 0' not working on > your router? > > > --asp > > > > I have the same problem here. Commands doing a lot of output hangs. > > If I do clogin -c "wr ter" on a device with a > large config > > clogin hangs. Likewise with "sh cam dyn" on some catalysts as well. > > > > I've basically used the same workaround, but also had to > add a prompt > > because one of my Cats changed the more prompt. > > can you tell me what operating system you are using and what > version of > expect/tcl? > I'm running this on Debian GNU/Linux 3.0r1 using only the debian packages. The version are: expect version 5.32.2 Tcl 8.3.3 I have tried the patch present on the rancid homepage, but it did not help much. It does seem like a different problem, as it work 100% as long as the output from any single command does not become to long. When a very verbose command is run it always hangs. I have been trying to establish it always occurs at the same bytecount of output but have not had that much time to pour into it just yet. Regards, Johan From: Russell Heilling To: rancid-discuss@shrubbery.net Subject: Fix for Rancid WARNING Processing Date: Sun, 9 Feb 2003 22:25:40 +0000 Message-ID: <20030209222540.GA7603@cricket.viatel.net> --wRRV7LY7NUeQGEoC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi All, The Rancid 2.2.2 code assumes that any WARNING messages in the output of "show version" will be 2 lines, however there is a warning type which only has one line. If you have a GRP in slot 12-15 in a GSR12016 show version recommends that you should only install RPs in slots 0-11. The following output illustrates the two warning types: --- show version output (snipped for brevity) --- WARNING: Old Rom Monitor in slot 15 Use "upgrade rom-monitor" command to update the image WARNING: Recommend RP for 12016 is in slot 0 - 11 rtr12016uktlh1# --- end output --- The attached diff modifies the default behaviour to only read a single line for the "Recommend RP" warning type. Regards, Russell Heilling -- Russell Heilling http://www.ccie.org.uk/ --wRRV7LY7NUeQGEoC Content-Type: text/plain; charset=us-ascii Content-Description: rancid.diff Content-Disposition: attachment; filename=diff --- ../rancid-2.2.2/bin/rancid 2003-02-08 20:15:10.699995000 +0000 +++ bin/rancid 2003-02-09 22:09:07.758479000 +0000 @@ -272,9 +272,13 @@ ProcessHistory("COMMENTS","keysort","I0","!\n"); } ProcessHistory("COMMENTS","keysort","I1","! $_"); - # The line after the WARNING is what to do about it. - $_ = ; tr/\015//d; - ProcessHistory("COMMENTS","keysort","I1","! $_"); + if (/Recommend RP/) { # RP Slot Warning is only single line + $_ = "\n"; + } else { + # The line after the WARNING is what to do about it. + $_ = ; tr/\015//d; + } + ProcessHistory("COMMENTS","keysort","I1","! $_"); } if (/^Configuration register is (.*)$/) { $config_register=$1; --wRRV7LY7NUeQGEoC-- From: "Rizzo, Joe" To: "Andrew Partan" , "Zhang, Anchi" Cc: Subject: RE: clogin -x fails when cisco prompt gets too long Date: Wed, 12 Feb 2003 15:32:01 -0800 Message-ID: <194487E5B6AC1E4E82FCBD56E5799791012D4310@eahq-mb3.rws.ad.ea.com> Would this be an acceptable fix: --- clogin.orig Wed Feb 12 15:24:34 2003 +++ clogin Wed Feb 12 15:23:52 2003 @@ -458,7 +458,7 @@ } regsub -all "\[)(]" $prompt {\\&} reprompt # match cisco config mode prompts too, but not for catalyst ie: (enable) - regsub -all "\[#>]$" $reprompt {(\\([^\\r\\n]+\\))?&} reprompt + regsub -all "\[#>]$" $reprompt {(\(config\))?&} reprompt expect { -re $reprompt {} -re "\[\n\r]+" { exp_continue } Thanks, Joe -----Original Message----- From: Andrew Partan [mailto:asp@partan.com] Sent: Wednesday, February 05, 2003 7:56 PM To: Zhang, Anchi Cc: rancid-discuss@shrubbery.net Subject: Re: clogin -x fails when cisco prompt gets too long On Mon, Feb 03, 2003 at 06:27:19PM -0600, Zhang, Anchi wrote: > It seems that clogin -x file will fail if the commands in file > result in a long prompt from the device. In the following example, > "REP2970_Server(config-router)#" would be expected after "router > eigrp 216" was sent. Shortening the hostname would make the script > work. $prompt is set to "REP2970_Server2B_L3#" & clogin is looking for this. Once you go into config mode, the prompt changes & $prompt no longer matches. Either write your own expect script & call it via 'clogin -s script', or stick your config comands into a rcp file & use util/cisco-load.exp, or do something like this: clogin -c "conf t\rrouter eigrp 216\reigrp log-neighbor-changes\rend;wr mem" --asp From: "Zhang, Anchi" To: "Rizzo, Joe" , "Andrew Partan" Cc: Subject: RE: clogin -x fails when cisco prompt gets too long Date: Wed, 12 Feb 2003 18:32:41 -0600 Message-ID: <4542F75EC5DC2E44AA0B648E20D00E352B0EB9@rriexmb10.services.reinternal.com> No, it does not seem to work; I am getting the same result. -anchi -----Original Message----- From: Rizzo, Joe [mailto:JRizzo@ea.com] Sent: Wednesday, February 12, 2003 5:32 PM To: Andrew Partan; Zhang, Anchi Cc: rancid-discuss@shrubbery.net Subject: RE: clogin -x fails when cisco prompt gets too long Would this be an acceptable fix: --- clogin.orig Wed Feb 12 15:24:34 2003 +++ clogin Wed Feb 12 15:23:52 2003 @@ -458,7 +458,7 @@ } regsub -all "\[)(]" $prompt {\\&} reprompt # match cisco config mode prompts too, but not for catalyst ie: (enable) - regsub -all "\[#>]$" $reprompt {(\\([^\\r\\n]+\\))?&} reprompt + regsub -all "\[#>]$" $reprompt {(\(config\))?&} reprompt expect { -re $reprompt {} -re "\[\n\r]+" { exp_continue } Thanks, Joe -----Original Message----- From: Andrew Partan [mailto:asp@partan.com] Sent: Wednesday, February 05, 2003 7:56 PM To: Zhang, Anchi Cc: rancid-discuss@shrubbery.net Subject: Re: clogin -x fails when cisco prompt gets too long On Mon, Feb 03, 2003 at 06:27:19PM -0600, Zhang, Anchi wrote: > It seems that clogin -x file will fail if the commands in file > result in a long prompt from the device. In the following example, > "REP2970_Server(config-router)#" would be expected after "router > eigrp 216" was sent. Shortening the hostname would make the script > work. $prompt is set to "REP2970_Server2B_L3#" & clogin is looking for this. Once you go into config mode, the prompt changes & $prompt no longer matches. Either write your own expect script & call it via 'clogin -s script', or stick your config comands into a rcp file & use util/cisco-load.exp, or do something like this: clogin -c "conf t\rrouter eigrp 216\reigrp log-neighbor-changes\rend;wr mem" --asp From: "Rizzo, Joe" To: "john heasley" , Subject: matching Cisco config prompt Date: Thu, 13 Feb 2003 07:09:49 -0800 Message-ID: <194487E5B6AC1E4E82FCBD56E5799791BC6660@eahq-mb3.rws.ad.ea.com> Mr. Heasley / Mr. Partan, Is this an acceptable way to match the Cisco prompt once in config mode? I.E. 'hostname(config)#', 'hostname(config-router)#', 'hostname(config-etc)#', etc diff -u clogin.orig clogin --- clogin.orig Wed Feb 12 15:33:02 2003 +++ clogin Wed Feb 12 16:30:56 2003 @@ -458,7 +458,7 @@ } regsub -all "\[)(]" $prompt {\\&} reprompt # match cisco config mode prompts too, but not for catalyst ie: (enable) - regsub -all "\[#>]$" $reprompt {(\\([^\\r\\n]+\\))?&} reprompt + regsub -all "\[#>]$" $reprompt {(\(config.*\))?&} reprompt expect { -re $reprompt {} -re "\[\n\r]+" { exp_continue } Thanks, Joe From: john heasley To: "Rizzo, Joe" Cc: john heasley , rancid-discuss@shrubbery.net Subject: Re: matching Cisco config prompt Date: Thu, 13 Feb 2003 10:09:03 -0800 Message-ID: <20030213180903.GG14931@shrubbery.net> References: <194487E5B6AC1E4E82FCBD56E5799791BC6660@eahq-mb3.rws.ad.ea.com> Thu, Feb 13, 2003 at 07:09:49AM -0800, Rizzo, Joe: > Mr. Heasley / Mr. Partan, > > Is this an acceptable way to match the Cisco prompt once in config mode? > I.E. 'hostname(config)#', 'hostname(config-router)#', > 'hostname(config-etc)#', etc unfortunately, i think this needs to be a little more involved. we need to take care of the following cases: - ios prompt foo[#>] - ios config prompt foo(config)# - ios truncated prompt somereallylongprompttrunc(config)# - catalyst prompt foo> - catalyst enable prompt foo (enable)> - catalyst - does the cat change the prompt in config mode? - catalyst - does the cat truncate long prompts? i need to get my catalyst running... > diff -u clogin.orig clogin > --- clogin.orig Wed Feb 12 15:33:02 2003 > +++ clogin Wed Feb 12 16:30:56 2003 > @@ -458,7 +458,7 @@ > } > regsub -all "\[)(]" $prompt {\\&} reprompt > # match cisco config mode prompts too, but not for catalyst ie: > (enable) > - regsub -all "\[#>]$" $reprompt {(\\([^\\r\\n]+\\))?&} reprompt > + regsub -all "\[#>]$" $reprompt {(\(config.*\))?&} reprompt > expect { > -re $reprompt {} > -re "\[\n\r]+" { exp_continue } > > Thanks, > Joe From: "Rizzo, Joe" To: "john heasley" Cc: , Subject: RE: matching Cisco config prompt Date: Fri, 14 Feb 2003 10:20:15 -0800 Message-ID: <194487E5B6AC1E4E82FCBD56E5799791BC6663@eahq-mb3.rws.ad.ea.com> Ah. I see. Thanks for the explanation. Anyway, the following seems to work on Cisco routers in any config mode and with truncated a prompt. diff -u clogin.orig clogin --- clogin.orig Wed Feb 12 15:33:02 2003 +++ clogin Fri Feb 14 10:11:04 2003 @@ -456,9 +456,9 @@ } else { send "term length 0\r" } - regsub -all "\[)(]" $prompt {\\&} reprompt + regsub -- {^(.{0,14}).*([#>])$} $prompt {\1\2} reprompt # match cisco config mode prompts too, but not for catalyst ie: (enable) - regsub -all "\[#>]$" $reprompt {(\\([^\\r\\n]+\\))?&} reprompt + regsub -all "\[#>]$" $reprompt {.*(\(config.*\))?&} reprompt expect { -re $reprompt {} -re "\[\n\r]+" { exp_continue } Thanks, Joe -----Original Message----- From: john heasley [mailto:heas@shrubbery.net] Sent: Thursday, February 13, 2003 12:09 PM To: Rizzo, Joe Cc: john heasley; rancid-discuss@shrubbery.net Subject: Re: matching Cisco config prompt Thu, Feb 13, 2003 at 07:09:49AM -0800, Rizzo, Joe: > Mr. Heasley / Mr. Partan, > > Is this an acceptable way to match the Cisco prompt once in config mode? > I.E. 'hostname(config)#', 'hostname(config-router)#', > 'hostname(config-etc)#', etc unfortunately, i think this needs to be a little more involved. we need to take care of the following cases: - ios prompt foo[#>] - ios config prompt foo(config)# - ios truncated prompt somereallylongprompttrunc(config)# - catalyst prompt foo> - catalyst enable prompt foo (enable)> - catalyst - does the cat change the prompt in config mode? - catalyst - does the cat truncate long prompts? i need to get my catalyst running... > diff -u clogin.orig clogin > --- clogin.orig Wed Feb 12 15:33:02 2003 > +++ clogin Wed Feb 12 16:30:56 2003 > @@ -458,7 +458,7 @@ > } > regsub -all "\[)(]" $prompt {\\&} reprompt > # match cisco config mode prompts too, but not for catalyst ie: > (enable) > - regsub -all "\[#>]$" $reprompt {(\\([^\\r\\n]+\\))?&} reprompt > + regsub -all "\[#>]$" $reprompt {(\(config.*\))?&} reprompt > expect { > -re $reprompt {} > -re "\[\n\r]+" { exp_continue } > > Thanks, > Joe From: john heasley To: "Rizzo, Joe" Cc: john heasley , rancid-discuss@shrubbery.net, AZhang@reliant.com Subject: Re: matching Cisco config prompt Date: Mon, 17 Feb 2003 06:06:27 +0000 Message-ID: <20030217060627.GC6508@shrubbery.net> References: <194487E5B6AC1E4E82FCBD56E5799791BC6663@eahq-mb3.rws.ad.ea.com> In-Reply-To: <194487E5B6AC1E4E82FCBD56E5799791BC6663@eahq-mb3.rws.ad.ea.com> Fri, Feb 14, 2003 at 10:20:15AM -0800, Rizzo, Joe: > Ah. I see. Thanks for the explanation. > > Anyway, the following seems to work on Cisco routers in any config mode > and with truncated a prompt. > > diff -u clogin.orig clogin > --- clogin.orig Wed Feb 12 15:33:02 2003 > +++ clogin Fri Feb 14 10:11:04 2003 > @@ -456,9 +456,9 @@ > } else { > send "term length 0\r" > } > - regsub -all "\[)(]" $prompt {\\&} reprompt > + regsub -- {^(.{0,14}).*([#>])$} $prompt {\1\2} reprompt > # match cisco config mode prompts too, but not for catalyst ie: > (enable) > - regsub -all "\[#>]$" $reprompt {(\\([^\\r\\n]+\\))?&} reprompt > + regsub -all "\[#>]$" $reprompt {.*(\(config.*\))?&} reprompt > expect { > -re $reprompt {} > -re "\[\n\r]+" { exp_continue } i think that is real close. need to test though. thanks joe. [ my cat5k is one weird duck...and stuck at ~ rev 2.4. trying to get my hands on something more recent ]