passing command line arguments to executable

Patrick Maupin pmaupin at gmail.com
Mon Apr 5 12:31:01 EDT 2010


On Apr 5, 11:22 am, mcanjo <mca... at gmail.com> wrote:
> On Apr 4, 6:32 am, Simon Brunning <si... at brunningonline.net> wrote:
>
>
>
> > On 3 April 2010 18:20, mcanjo <mca... at gmail.com> wrote:
>
> > > I tried doing the following code:
>
> > > from subprocess import Popen
> > > from subprocess import PIPE, STDOUT
> > > exefile = Popen('pmm.exe', stdout = PIPE, stdin = PIPE, stderr =
> > > STDOUT)
> > > exefile.communicate('MarchScreen.pmm\nMarchScreen.out')[0]
>
> > > and the Command Prompt opened and closed, no exceptions were generated
> > > but the program didn't run. Am I doing something wrong?
>
> > Have you tried running pmm.exe from the command line? What does that
> > look like? Does it matter what the current working directory is at the
> > time?
>
> > --
> > Cheers,
> > Simon B.
>
> When I run the program from the command line it looks as follows:
>
> Enter the Input filename
> (enter in filename here)
> Enter the Output filename
> (enter in filename here)
>
> If an absolute path is not specified then the output file is located
> in the current working directory of the executable. The absolute path
> for the output and input files may be specified also.
>
> Chris

One thing you should do if you use pipes is to make sure you are
accepting data from the program.  If the program stalls because it
cannot write anything to its stdout, you might have an issue.

Pat



More information about the Python-list mailing list