|
|
 |
 |
 |
 |
Python Programming Language
|
 |
 |
 |
 |
 |
 |
 |
 |
using telnetlib
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") >>> tn.read_until("Login: ") '\r\nLogin: ' >>> tn.write("root\n:") >>>tn.read_until("Password: ")
Cursor stays over here forever!. Delays are not working. I tried all the codes mentioned n c.l.p, but i have not yet been able to get telnetlib working. Any suggestions as how to troubleshoot and resolve this issue? Thanks, Senthil
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, Bjrn -- BOFH excuse #88: Boss' kid fucked up the machine
On Feb 28, 4:15 pm, Bjoern Schliessmann <usenet- mail-0306.20.chr0n @spamgourmet.com> 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 be on the > safe side.
Thanks a lot, Bjrn. That did help and solved my problem. ":" after \n was just a typo. -- Senthil
|
 |
 |
 |
 |
|