Controlling an external program with Python

Mark C Favas mark at chem.uwa.edu.au
Wed Jun 28 00:09:22 EDT 2000


Donn Cave <donn at u.washington.edu> writes:

>Quoth ge at nowhere.none (Grant Edwards):
>| In article <kuzoobue0g.fsf at lasipalatsi.fi>, Erno Kuusela wrote:
>|>>>>>> "Tony" == Tony Keating <keating at mech.uq.edu.au> writes:
>|>
>|>    Tony> start the program, then send various strings to the program,
>|>    Tony> read some output from the program then send some more
>|>    Tony> strings to the program.
>|>
...
<snip>
...
>|
>| Or you can roll your own using the popen2 module.

>OK, but check to see if your application will work reliably on
>a pipe, before you put too much work a pipe solution.  I append
>a short sample program that works with the shell as a remote
>application, but deadlocks with awk.  The awk behavior is what
>I would expect from most programs, so normally you're sunk.

If it won't work with pipes, have a look at the pty library module...

Cheers,
	Mark
--
Email  - mark at chem.uwa.edu.au      ,-_|\                           Mark C Favas
Phone  - +61 9 380 3482           /     \               Department of Chemistry
Fax    - +61 9 380 1005      ---> *_,-._/   The University of Western Australia
                                       v                               Nedlands
Loc    - 31.97 S, 115.81 E                               Western Australia 6009



More information about the Python-list mailing list