I have been trying for several weeks now to write a program that allows
me to read the stdout of a process that I spawn and once I receive
feedback, act appropriately.

More specifically, I need to create an SSH tunnel using plink on
Windows XP. Once the tunnel is successfully created, then I need to run
my program over that tunnel. If there is an error in the creation of
the tunnel, then I need to abort and warn the users.

My needs are 'small' but I just lack the know-how to get it done. I
need to be able to spawn off plink so that it can continue to run in
the background without interferring with the flow of my program.
However, I would like to get the feedback to know if/when a successful
connection has been made so that I know the appropriate actions to
take.

In the past, I spawned off a process using os.spawnl set into a thread
and would pause for 10 seconds to give plink time to connect. However,
it probably goes without saying this is not the best solution by any
stretch of the imagination.

My old command was (with obviously fake data):
os.spawnl(os.P_NOWAIT, 'plink', 'plink', '[EMAIL PROTECTED]', '-N',
'-L 111:200.200.200.200:7000')
Then I would poll Windows to see if plink had started. If it hadn't
started, I would raise an exception. However, there are plenty of times
where plink starts but no connection is made.

As with most questions like this one, any and all help would be greatly
appreciated.

Lewis

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to