Need help with telnetlib flakiness

Stephen Ferg steve at ferg.org
Wed Feb 4 21:36:45 CET 2004


I'm trying to use telnetlib to run a Java program on a remote server. 
I'm having strange problems, and I'm wondering if anyone might be able
to help.

I have two UNIX servers, A and Z.  

I have an application named LATTE that runs on server A.  When the
user starts LATTE, the user can choose to create a telnet connection
back to A, or to Z.  Then LATTE uses the telnet connection to run a
Java program (run it several times, on different input files) on the
selected server.   After each run, it uses read_until() to wait from
the prompt to reappear before running the program on the next input
file.

I have no problems when LATTE is connecting back to A.  Everything
works fine.  But when connecting to Z, strange things happen.  The
program runs fine on the first file, then on subsequent files does
nothing but write a series of beeps (\x07) to the console until the
telnet connection read_until() times out.

I've checked out all the reasonable possibilities : differences in
executables, differences in input files, which file is the first to be
processed,  etc.  The problem is not in the command itself --  on Z, I
can run the program just fine on each input file if I execute the
identical command from an interactive telnet prompt.

So I appear to be getting the flaky behavior only when running the
program via Python's telnetlib (not interactively from the console),
when connected to the remote server (Z), not the home server (A), only
on the second and subsequent input files (not on the first).

I'm buffaloed.  Does anybody have any ideas what might be going on? 
Is telnetlib reliable?

-- Steve Ferg

P.S. Here's my code:
=============================

cmd = ("java " + classpathSpec
         +" " + classfileName
         +" " + inFilename
         )
cmd += "\n" 

argTelnetConnection.write(cmd)
     
results = argTelnetConnection.read_until(argPromptString,30)



More information about the Python-list mailing list