Calling external program from within python

2008-07-25 Thread Emmanouil Angelakis
Hi, I am tryiong to do something obviously trivial such as: I have a c program called tsys2list that when it is ran it asks the user to give the value of tcal which is a variable. I want to call the tsys2list from within a pyrthon script lets call it gamma.py but I want to pass the value of

Re: Calling external program from within python

2008-07-25 Thread Mike Driscoll
On Jul 25, 7:56 am, Emmanouil Angelakis [EMAIL PROTECTED] wrote: Hi, I am tryiong to do something obviously trivial such as: I have a c program called tsys2list that when it is ran it asks the user to give the value of tcal which is a variable. I want to call the  tsys2list from within a

Re: Calling external program from within python

2008-07-25 Thread Diez B. Roggisch
Mike Driscoll schrieb: On Jul 25, 7:56 am, Emmanouil Angelakis [EMAIL PROTECTED] wrote: Hi, I am tryiong to do something obviously trivial such as: I have a c program called tsys2list that when it is ran it asks the user to give the value of tcal which is a variable. I want to call the

Re: Calling external program from within python

2008-07-25 Thread Grant Edwards
On 2008-07-25, Diez B. Roggisch [EMAIL PROTECTED] wrote: There are probably many ways to do this. I would recommend checking out the subprocess module and see if it does what you want. This will only work if the program can be fully controlled by commandline arguments. Why do you say

Re: Calling external program from within python

2008-07-25 Thread Diez B. Roggisch
Grant Edwards schrieb: On 2008-07-25, Diez B. Roggisch [EMAIL PROTECTED] wrote: There are probably many ways to do this. I would recommend checking out the subprocess module and see if it does what you want. This will only work if the program can be fully controlled by commandline arguments.

Re: Calling external program from within python

2008-07-25 Thread oj
On Jul 25, 3:44 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Because usually if a program *prompts* the user to enter input (and that was what I read from the OP's post), one has to deal with pseudo terminals, not with stdin/out. How does the program writing some text before taking input

Re: Calling external program from within python

2008-07-25 Thread Diez B. Roggisch
oj schrieb: On Jul 25, 3:44 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Because usually if a program *prompts* the user to enter input (and that was what I read from the OP's post), one has to deal with pseudo terminals, not with stdin/out. How does the program writing some text before

Re: Calling external program from within python

2008-07-25 Thread Marc 'BlackJack' Rintsch
On Fri, 25 Jul 2008 08:13:55 -0700, oj wrote: On Jul 25, 3:44 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Because usually if a program *prompts* the user to enter input (and that was what I read from the OP's post), one has to deal with pseudo terminals, not with stdin/out. How does the

Re: Calling external program from within python

2008-07-25 Thread Mike Driscoll
On Jul 25, 9:28 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: Mike Driscoll schrieb: On Jul 25, 7:56 am, Emmanouil Angelakis [EMAIL PROTECTED] wrote: Hi, I am tryiong to do something obviously trivial such as: I have a c program called tsys2list that when it is ran it asks the user

Re: Calling external program from within python

2008-07-25 Thread Diez B. Roggisch
Mike Driscoll schrieb: On Jul 25, 9:28 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: Mike Driscoll schrieb: On Jul 25, 7:56 am, Emmanouil Angelakis [EMAIL PROTECTED] wrote: Hi, I am tryiong to do something obviously trivial such as: I have a c program called tsys2list that when it is ran it

Re: Calling external program from within python

2008-07-25 Thread Michael Tobis
These answers are too elaborate and abstract for the question. Emmanouil, Here is a program myprog which takes input and writes output to a file. It happens to be python but it could be anything. # #!/usr/bin/env python a = int(raw_input(enter thing 1 )) b = int(raw_input(enter thing 2 )) c

Re: Calling external program from within python

2008-07-25 Thread Grant Edwards
On 2008-07-25, Diez B. Roggisch [EMAIL PROTECTED] wrote: Because usually if a program *prompts* the user to enter input (and that was what I read from the OP's post), one has to deal with pseudo terminals, not with stdin/out. If interaction is required, the OP might consider using

Re: Calling external program from within python

2008-07-25 Thread Terry Reedy
Michael Tobis wrote: For some reason os.popen is deprecated in favor of the more verbose subprocess.Popen, but this will work for a while. As explained in http://www.python.org/dev/peps/pep-0324/ subprocess consolidated replaced several modules and functions (popen*, system, spawn*,