[Tutor] Print list vs telnetlib.telnet.write differences

Python python at venix.com
Tue Mar 7 05:29:20 CET 2006


On Tue, 2006-03-07 at 13:39 +1000, STREET Gideon (SPARQ) wrote:
> The second banner exec is red, the previous commands I send are in
> green.  So I take it to mean that it is an echo produced by the router.
> MMmm strange as the echo is overwriting what I'm sending initially.

Well the device is designed for interactive use by a human who does not
spew characters nearly has quickly as your script.  In this case you
probably need to read the response to the exec banner command before
sending the banner.  Most commands are done in a single line, but banner
is an exception.

This kind of scripting is often done with expect and I believe that
there is some expect-like module for Python.

As I suggested earlier, getting tftp to send command files will make a
much better long term solution.  This script would only have to manage
logging in and starting tftp.  Once that works all other commands would
be in the file that tftp transfers.  Linux/Unix systems already have
tftp built in.  Cisco provides a tftp implementation for Windows.

It is easy to put comments into the command files and also use
subversion or some other version control package to track changes.

> 
> The banner appears to work but is then overwritten, maybe I need to come
> up with another way of sending the commands so I get around the echo.
> 
> Thanks
> 
> Gideon
> 
> -----Original Message-----
> From: tutor-bounces at python.org [mailto:tutor-bounces at python.org] On
> Behalf Of Python
> Sent: Tuesday, 7 March 2006 12:52 PM
> To: Tutor Python
> Subject: Re: [Tutor] Print list vs telnetlib.telnet.write differences
> 
> On Tue, 2006-03-07 at 11:31 +1000, STREET Gideon (SPARQ) wrote:
> > Enter configuration commands, one per line.  End with CNTL/Z.
> > switch01(config)#banner exec ^
> >
> >  ##################################################
> >
> >                      switch01
> >
> >         Level XX, XX Some Street, Somewhere
> >        Site contact: John Citizen 555 5555
> >      System Contact: Helpdesk  555 5556
> >
> >  ##################################################
> >
> >  ^
> > banner exec ^  <---- this is the second time this command is sent to
> > the device Enter TEXT message.  End with the character '^'.
> >
> >  ###exit
> > ############
> 
> My tcpwatch.py display shows different colors for each side of the
> conversation.  Do you get two colors?  are both in the same color?
> 
> Isn't the second banner exec simply the echo back from the cisco device?
> It is giving you your entry instructions.
> 
> 1.  Is the banner exec command working?
> If it works, then the funny duplication is almost certainly just an
> artifact of characters getting echoed from the cisco device.
> 
> --
> Lloyd Kvam
> Venix Corp
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 
> 
> This e-mail (including any attachments) may contain confidential or
> privileged information and is intended for the sole use of the person(s) to
> whom it is addressed. If you are not the intended recipient, or the person
> responsible for delivering this message to the intended recipient, please
> notify the sender of the message or send an e-mail to
> mailto:help.desk at ergon.com.au immediately, and delete all copies. Any
> unauthorised review, use, alteration, disclosure or distribution of this
> e-mail by an unintended recipient is prohibited. Ergon Energy accepts no
> responsibility for the content of any e-mail sent by an employee which is of
> a personal nature.
> 
> Ergon Energy Corporation Limited      ABN 50 087 646 062
> Ergon Energy Pty Ltd      ABN 66 078 875 902
-- 
Lloyd Kvam
Venix Corp



More information about the Tutor mailing list