[Tutor] [Fwd: Python -Telnet problem]

Rams Subramonian ramas@retriever.com.au
Tue, 15 May 2001 20:26:25 +1000


This is a multi-part message in MIME format.
--------------DCD14D4903F3C0886D749E48
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

The following script sometimes doesn't work in Python scripting; It does

not go past the login  command  but seems to work interactively  with a
manual telnet session.
Any suggestions ?


 !/usr/bin/env python

import sys
import telnetlib


tn = telnetlib.Telnet("xxx", 4333)              # works ok

tn.set_debuglevel(30)
s=tn.read_eager()                                       #not ok
print s                                                           # not
ok
s=tn.read_eager()                                       # not ok
print s
tn.write("login xx cccc" + "\r\n")               # ok

s=tn.read_eager()                                        # not ok
print s                                                             #not
ok
tn.write("send xx  hello" + "\r\n")               #not ok
s=tn.read_eager()                                        #not ok
print s
tn.write("bye" + "\r\n")

tn.read_eager()
tn.read_eager()





--------------DCD14D4903F3C0886D749E48
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

X-Mozilla-Status2: 00000000
Message-ID: <3AFF65D6.1E39A53D@retriever.com.au>
Date: Mon, 14 May 2001 14:57:58 +1000
From: Rams Subramonian <ramas@retriever.com.au>
Reply-To: ramas@retriever.com.au
Organization: Retriever communications
X-Mailer: Mozilla 4.72 [en] (X11; U; Linux 2.2.14-5.0 i686)
X-Accept-Language: en
MIME-Version: 1.0
To: python-help@python.org
Subject: Python -Telnet problem 
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

The following script sometimes doesn't work in Python scripting; It does
not go past the telnet constructor(localhost) command but seems to work
interactively  with a manual telnet session.
Any suggestions ?

#!/usr/bin/env python
#
import os
import sys
import telnetlib
import string


tn = telnetlib.Telnet("localhost")
tn.set_debuglevel(30)
s   = tn.read_until('login:')
tn.write("help" + "\r\n")
s=tn.read_all()
print "got %s" % s

tn.close()
exit


--------------DCD14D4903F3C0886D749E48--