Telnet problems

jestes39 at yahoo.com jestes39 at yahoo.com
Wed May 23 09:30:16 EDT 2001


I am new to Python and I need some assistance with an issue I'm 
having. Here is the login script that I am using to connect to a SCO 
UNIX box from my NT workstation. I have successfully logged in, but 
when the session gets to the point where it needs to display color, 
it gives me the message: 'I need to know a more specific terminal 
type than "network".' I can login using Kermit and negotiate all the 
necessary screens without any problems, but I don't think Python can 
emulate the vt320 that the UNIX box wants it to use. Again, I am not 
an expert at all so this is just a guess.

  import sys
  import telnetlib

  try:
      tn = telnetlib.Telnet('XXX.XXX.XXX.XXX')
  except:
      print 'couldn''t open telnet connection'

  try:
      tn.set_debuglevel(10)
  except:
      print 'couldn''t set the debug level'

  try:
      tn.read_until("login: ")
  except:
      print 'didn''t get the login prompt'

  try:
      tn.write("jason\r\n")
  except:
      print 'couldn''t enter the username'

  try:
      tn.read_until("Password:")
  except:
      print 'didn''t get the password prompt'

  try:
      tn.write("XXXXXXXX\r")
  except:
      print 'didn''t like the password or how I wrote it'

  tn.read_until("PROGRAM ID........: ")

The script never gets to this last line. I used a loop with 
tn.Read_Eager() calls to see what I was getting. I get the correct 
info until it switches to the vt320 emulation. I am basically trying 
to push commands to this application on the UNIX box via Python's 
telnet session. I will screen-scrape to get the results.

1. Am I making this too difficult? i.e. Is there an easier way to do 
this that I am not aware of?

2. Is there a way that I can tell Python to ignore the colors or 
whatever it is balking at?

3. Is there something on the UNIX box that I need to change?

Any comments will be appreciated. Thanks in advance.
You can reply to this e-mail or send me a message at work: 

jestes3 at logicon.com







More information about the Python-list mailing list