Re: using telnetlib

2007-02-28 Thread Bjoern Schliessmann
Phoe6 wrote: > That did help and solved my problem. ":" after \n was just a typo. Thanks for feedback :) I've had a similar problem once, too. Regards, Björn -- BOFH excuse #166: /pub/lunch -- http://mail.python.org/mailman/listinfo/python-list

Re: using telnetlib

2007-02-28 Thread Phoe6
On Feb 28, 4:15 pm, Bjoern Schliessmann wrote: > Phoe6 wrote: > import telnetlib > tn = telnetlib.Telnet("172.31.128.244") > tn.read_until("Login: ") > > '\r\nLogin: ' > tn.write("root\n:") > >^^^ > > With telnet, use "\r\n" for line breaks at *all* times to

Re: using telnetlib

2007-02-28 Thread Bjoern Schliessmann
Phoe6 wrote: import telnetlib tn = telnetlib.Telnet("172.31.128.244") tn.read_until("Login: ") > '\r\nLogin: ' tn.write("root\n:") ^^^ With telnet, use "\r\n" for line breaks at *all* times to be on the safe side. Also, what's the ":" at the end for? Regards

using telnetlib

2007-02-28 Thread Phoe6
Hi All, I am trying to use the telnetlib module. Manually when I do telnet 172.31.128.244 I get: Login: (I type root) Password: ( I type Password) And it enters to the Telnet Session: [root]# Now, I am trying to use telnetlib module >>> import telnetlib >>> tn = telnetlib.Telnet("172.31.128.244"

Re: Help please using telnetlib module

2006-12-24 Thread Birdman
Simplest explanation is that you can't do a 'show run' from global configuration mode try something like #exit global configuration mode tn.write('end\n') print tn.read_until('#') #disable pause after 24 lines tn.write('term len 0\n') tn.read_until('#') #now show the entire running-config t

Help please using telnetlib module

2006-12-23 Thread dudds
Hi Guys, I just started learning Python a couple of days ago and to put some of what I learnt into practice. As such I thought I might try and write a simple program (based on examples I had seen) that would allow me to log into a Cisco router, enter configuration mode, change an interface descrip

Re: How to know if connection is active when using telnetlib?

2005-08-26 Thread Wojciech Halicki-Piszko
> If open() doesn't throw an exception then you should have a connection you can > start reading/writing with. Unless you have some special meaning for > 'active'? > > I'm just basing this on reading telnetlib.py. > > Eddie Well, in fact what I meant is: I won't to check wether established conn

Re: How to know if connection is active when using telnetlib?

2005-08-26 Thread [EMAIL PROTECTED]
Well, running this code: -- >>> import telnetlib >>> c = telnetlib.Telnet("blah") -- throws this exception: -- socket.gaierror: (11001, 'getaddrinfo failed') -- note that this is the same as your "telnetlib.Telnet.open". So, you will want to use TRY: and EXCEPT: to

Re: How to know if connection is active when using telnetlib?

2005-08-26 Thread Eddie Corns
Wojciech Halicki-Piszko <[EMAIL PROTECTED]> writes: >How to know if connection is active after telnetlib.Telnet.open(host,port)? If open() doesn't throw an exception then you should have a connection you can start reading/writing with. Unless you have some special meaning for 'active'? I'm just

How to know if connection is active when using telnetlib?

2005-08-26 Thread Wojciech Halicki-Piszko
How to know if connection is active after telnetlib.Telnet.open(host,port)? -- http://mail.python.org/mailman/listinfo/python-list