Mailing List Archive

matching Cisco config prompt
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
matching Cisco config prompt [ In reply to ]
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
matching Cisco config prompt [ In reply to ]
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
matching Cisco config prompt [ In reply to ]
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 ]