python telnet script for openvms host

Ennis Rosamond ennisr at my-deja.com
Tue Dec 26 11:58:35 EST 2000


I am attempting to develop a Python telnet script to access
an OpenVMS host.

The script is partially successful in that it logs on to the
target host. I know this because following acceptance of the
user password by the host, the host sends back the same header
message as is received in an interactive telnet session.  The
problem I am having is that the host doesn't seem to be sending
back a '$ ' prompt after the session header; at least I haven't
seen it.  Consequently, the host doesn't respond to any commands
sent by the script.
(I have been trying a simple '$ dir' command.)

My test script is listed below.

#python test script:
import sys, telnetlib
host = 'hostname'
user = 'username\r'
password = 'mypasswd\r'
tn = telnetlib.Telnet(host)
tn.read_until('Username: ')
tn.write(user)
tn.read_until('Password: ')
tn.write(password)
tn.read_until('[c')    #last char of session hearder
tn.write('$ dir\r')

#following this, I receive back the sequence:
#recv '\377\373\001'
#IAC WILL 251
#recv '\377\373\003'
#IAC WILL 251
#recv '\003\\\033Z'
#
#which I don't know how to interpret.

Anyone have an idea about how to determine what I am doing
wrong?  Could the problem have something to do with the
terminal type expected by the OpenVMS telnet host?

I am posting this to both the python and openvms discussion
groups.  Any help greatly appreciated.


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list