Prompt issues on Bay routers.
James Kilton
kilton9 at yahoo.com
Mon Sep 29 13:26:07 UTC 2003
Mark Cooper wrote:
> OK, as I see it ( and please dont take this the wrong way,
> I'm jut trying to work out what the differences are ) ....
Heh, not to worry. I'm by no means a programmer and hacked around with
the Rancid code until I finally stumbled upon something that worked.
Nothing will hurt my feelings here. ;-)
> [root at dire new]# diff -b blogin blogin.james
> 441a443
> > -re "bcc>" {}
> 449a452
> > -re "bcc>" {}
> 483c486
> < set prompt "#"
> ---
> > set prompt {TN}
> 486c489
> < set prompt "$"
> ---
> > set prompt ">"
>
> You've added a prompt condition check for "bcc>" in the
> run_commands function. I'm sure blogin should handle the
> reprompt normally, but thats probably if it already has
> the prompt using a ">".
The primary issue to my untrained eye seemed to be the change of prompt
when going from the TI interface to BCC. So most of the time I spent on
this was spent trying to figure out how to get the scripts to first
recognize the TI prompt, then change to the BCC prompt after running the
'bcc' command.
> You've changed the prompt in the enabled ( # to {TN} )
> and non-enabled ( $ to > ) states. This seems strange as
> the Bay's don't have an 'enabled' state?
Some of my changes likely aren't necessary - I kept trying things until I
had success and didn't go back afterwards to determine for sure what
changes were and weren't necessary. The change to '{TN}' above is
necessary in my versions though - if I replace it with something else,
blogin never executes the initial 'bcc' command. But the change from '$'
to '>' may not be - I changed it back and was still able to login and run
commands.
> If you could post the session details of a full login to bcc
> and back out I would appreciate it :)
Sure thing:
------------------------------------------------------
[rancid at syslog bin]$ ./blogin -c "bcc;show system memory;exit" 10.0.0.1
10.0.0.1
spawn telnet 10.0.0.1
Trying 10.0.0.1...
Connected to 10.0.0.1.
Escape character is '^]'.
Nortel Networks, Inc. and its Licensors.
Copyright 1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002.
All rights reserved.
Login:
Password:
Welcome to the Backbone Technician Interface
Mounting new volume...
Device label:
Directory: 1:
New Present Working Directory: 1:
[1:TN]$ more off
More Mode: OFF
Lines per screen: 44
[1:TN]$ bcc
Welcome to the Bay Command Console!
* To enter configuration mode, type config
* To list all system commands, type ?
* To exit the BCC, type exit
bcc> show system memory
show system memory Sep 29, 2003 12:29:41
[GMT]
Memory Usage Statistics (Megabytes):
------------------------------------
Slot Total Used Free %Free
---- -------- -------- -------- -------
1 21.09 M 6.63 M 14.46 M 68%
bcc> exit
[1:TN]$ logout
TI session logged out.
** Goodbye. **
Connection closed by foreign host.
------------------------------------------------------
> [root at dire new]# diff -b brancid brancid.james
> 147c147
> < next if (/^\# *uptime +\d+\s*$/);
> ---
> > next if (/^\# *uptime +-?\d+\s*$/);
> 188d187
> < 'show config' => "ShowConfig",
> 196d194
> < "show config",
> 235c233
> < if ( (/\>\s?logout$/) || $found_end ) {
> ---
> > if ( (/>\s?exit$/) || $found_end ) {
> 245c243
> < while (/>\s*($cmds_regexp)\s*$/) {
> ---
> > while (/>\s*($cmds_regexp)\s*$/ | /\$\s*($cmds_regexp)\s*$/) {
> 262a261,263
> > if ( (/>\s?exit$/) || $found_end ) {
> > $clean_run=1;
> > }
> 287a289
>
> You've made a change to the parsing of the uptime section of
> the config, no problem.
Yes, this was to combat a BCC bug where the uptime value is sometimes a
negative number.
> You've removed the first "show config" command to just leave
> the "show config -all", no problem.
'show config' shows the first few lines or so of 'show config -all' (the
software build date, SNMP contact info, and uptime), so the latter command
is the only one I was interested in.
> You've changed the check for the successful end of the session from
> looking for the "logout" command to looking for an "exit" command.
> I don't think this is right, as you will be catching the exit from
> bcc and not fully logging out.
This was another thing that I had trouble with and had to work around in
an ugly fashion. Once the prompt issues were resolved I was successfully
logging in, running commands, and logging out, but the script still wasn't
detecting the end of session properly and was hence giving an error. It
turns out that a simple 'logout' from BCC will log you out of the router
(i.e., no need to do 'exit' first), so it might be the case that the 'end
of session' code would work as is when 'logout' is run in of itself. I
haven't tried it, though.
> Carnt work out line 245 ( it's five am in the morning and I'm very
> tired ) but it looks like you've added a check for prompts containing
> "$"??
Yep and this was a required change. Otherwise I get "missed cmd(s): bcc".
My guess was/is that the original code never enters the 'while' loop when
'bcc' is run because it is run from the TI prompt which ends in '$'.
> Could you tell me what piece of bay kit your trying to login to and
> what the OS version is?
I'm primarily using ARN routers running code version 14.0 and 15.2.
> At the minimum, the login prompt needs fixing! This can be fixed
> like this:-
My versions actually work without this change. Don't know how though. ;-)
> It seems that the initial prompt is always "$" which is what blogin
> originally expected so I'm not sure why this is giving a problem?
The problem for me was the prompt change upon execution of the 'bcc'
command. I was originally going to try to have the code treat the 'bcc'
command like the 'enable' command and work from there (because the code as
is expects a prompt change there), but I ended up going the ugly route
instead.
> Again, copies of a typical full login ( through to bcc ) would be be
> helpful, as well as the output from the following:-
>
> blogin -c 'bcc; show config' routername
Posted above, though I ran "show system memory" instead to avoid having to
post a long config.
> setenv NOPIPE=YES;brancid -d routername ( post the .raw file left behind
)
Here's the .raw file, but again with a shorter command:
--------------------------------------------------------
[rancid at syslog ~/bin]$ cat 10.0.0.1.raw
10.0.0.1
spawn telnet 10.0.0.1
Trying 10.0.0.1...
Connected to 10.0.0.1.
Escape character is '^]'.
Nortel Networks, Inc. and its Licensors.
Copyright 1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002.
All rights reserved.
Login:
Password:
Welcome to the Backbone Technician Interface
Mounting new volume...
Device label:
Directory: 1:
New Present Working Directory: 1:
[1:TN]$ more off
More Mode: OFF
Lines per screen: 44
[1:TN]$ bcc
Welcome to the Bay Command Console!
* To enter configuration mode, type config
* To list all system commands, type ?
* To exit the BCC, type exit
bcc> show system memory
show system memory Sep 29, 2003 13:03:04
[GMT]
Memory Usage Statistics (Megabytes):
------------------------------------
Slot Total Used Free %Free
---- -------- -------- -------- -------
1 21.09 M 6.64 M 14.44 M 68%
bcc> exit
[1:TN]$ logout
TI session logged out.
** Goodbye. **
Connection closed by foreign host.
--------------------------------------------------------
> Hope that all helps :)
By all means, let me know if you need anything else. I'm happy to help.
More information about the Rancid-discuss
mailing list