From: Ed R. <er...@pa...> - 2002-04-17 16:21:44
|
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 |