How to run external program?

Lad python at hope.cz
Fri Jan 12 05:06:41 EST 2007


Gary Herron wrote:
> Lad wrote:
> > How  can I run external program from Python?
> > I use Python with XP
> > Thank you for help
> > LB
> >
> >
> The subprocess module is what you want for this.
>
> It's got ways of running external executables as separate subprocesses,
> and interacting with the subprocess and both its input and output.
>
 Gary ,
Thank you for your reply.
I use os.popen3 but it does not work properly for me all the time.

Here is a part of my Python  program
I use an external  program ( here mpeg.exe) for converting sourcefile
into targetfile
###########...
...
...
mpeg = "mpeg.exe -i %s codec mp3  -s 320x240 %s" % (sourcefile,
targetfile)
stdin, stdout, stderr = os.popen3(mpeg)
mpegresult = stdout.read()
mpegerrors = stderr.read()
stdin.close(); stdout.close(); stderr.close()
print ffmpegerrors
print ffmpegresult
#########

It works  if the sourcefile is small but if it is large( 30MB) it does
NOT work.It hangs or the file is not converted in full.
Any advice how I should change the program?
Thank you.
L.




More information about the Python-list mailing list