Running a python script from JAVA, with correct indentation

Alain saraz at videotron.ca
Fri Feb 4 15:04:18 CET 2000


Here's the python code of my script:
import telnetlib

telnet = telnetlib.Telnet()
telnet.set_debuglevel(2)
telnet.open ('132.208.135.240',23)
telnet.write('\n')
telnet.read_until('Password:')
telnet.write('fixit\n')
telnet.read_until('>')
telnet.write('enable\n')
telnet.read_until('Password:')
telnet.write('laboinfo\n')
telnet.read_until ('#')
telnet.write('configure terminal\n')
telnet.read_until ('#')
telnet.write ('access-list 99 permit 111.111.0.0 0.0.255.255\n')
telnet.read_until('#')
telnet.write('access-list 99 permit 111.111.0.0 0.0.255.255\n')
telnet.read_until('#')
telnet.write('access-list 99 permit 111.111.0.0 0.0.255.255\n')
telnet.read_until('#')
telnet.write ('interface Ethernet 0/1 \n')
telnet.read_until ('#')
telnet.write ('ip access-group 99 IN \n')
telnet.read_until ('#')
telnet.write ('exit \n')
telnet.read_until ('#')
telnet.write ('exit \n')
telnet.read_until ('#')
telnet.write ('exit \n')

Any idea?

David Fisher <python at rose164.wuh.wustl.edu> a écrit dans le message :
20000204.9584017 at sparky.spkydomain...
>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<

On 2/3/00, 3:12:09 PM, "Alain" <saraz at videotron.ca> wrote regarding
Running a python script from JAVA, with correct indentation:

> Hi,

> I'm trying to run a script from a file. The script is written in
python. The
> script is a telnet session between a router and a computer. If I run
the
> script from a DOS prompt window, everything is good. But if I start
the
> script from my program, using a Runtime object, there's a problem. The
> communication between the router and the computer is stop, even if the
> telnet session is still open. Here's the JAVA code:
[...]
> Is there someone have a solution?

Well, this is a blind guess without seeing the python code, but are
you using os.popen() somewhere?  The windows C-runtime has a problem
redirecting console i/o if there isn't a console open (like a dos
window).  So this could describe your problem.  Look at the python FAQ
for "popen" for more info.

When-all-you-have-is-a-hammer-everything-looks-like-a-nail-ly yr's
david










More information about the Python-list mailing list