From: <Tin...@Te...> - 2002-04-17 20:21:56
|
Hi, Ed, Thanks for your help. I am actually interacting with a Riverstone router. A similar command on Riverstone is cli set terminal rows 0, but I am still seeing some control characters. Can you explain a little about "# ", try "^[^#]+# "? ^ means the beginning of the line, + means one or more of the previous character, [] means any one of the characters in the [], right? I don't see how it can used to match new prompt? Thanks again. Ting > -----Original Message----- > From: Ed Ravin [mailto:er...@pa...] > Sent: Wednesday, April 17, 2002 9:22 AM > To: Ting Cai > Cc: exp...@li... > Subject: Re: [Expectperl-discuss] unexpected \r and other chars. > > Tin...@Te... writes: > > I am seeing a bunch of extra characters inserted between the command I > sent. > > I sent 'copy startup to bootflash:lab-baseline.conf\n', but the string > used > > in matching is: > > > > ---- > > Does `copy \033[?25l\rlab1nnisaa02.lab# copy > > > \015\033[C\033[C\033[C\033[C\033[C\033[C\033[C\033[C\033[C\033[C\033[C\033 > [C > > \033[C' > > Looks like you're talking to a Cisco router, and the router is sending > terminal escape codes as part of its echoback. I see "<esc> [ ? 25 l" > (some kind of reset mode command) and lots of "<esc> [ C" (cursor right). > The Cisco is probably trying to do command line editing or otherwise > reformatting the echo of your input to make things look nice. > > You need to send "terminal width 0" and "terminal length 0" to the router > before starting to interact with it. That will keep the Cisco from > sending > screen formatting codes to the terminal, or from pausing during the > output of multi-line commands. > > Feel free to steal code from aclmaker, a tool I wrote that interacts > with Cisco routers to manage access control lists - it's over at: > > http://prdownloads.sourceforge.net/cosi-nms/aclmaker-perl-1.02.txt > > See the subroutines "open_router" and "get_prompt" in that program for > how I dealt with some of these issues. > > You probably also want to make your match strings more precise - > instead of "# ", try "^[^#]+# " to match a new router prompt, > and " \[no\]" to match the confirmation question. Or you can steal > aclmaker's logic, which discovers the router's prompt dynamically > and tries to match that during subsequent commands. > > -- Ed |