Mailing List Archive

clogin -x fails when cisco prompt gets too long
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 at 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%
clogin -x fails when cisco prompt gets too long [ In reply to ]
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
clogin -x fails when cisco prompt gets too long [ In reply to ]
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
clogin -x fails when cisco prompt gets too long [ In reply to ]
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 at 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