redirect or cover .bat log

vedrandekovic at v-programs.com vedrandekovic at v-programs.com
Wed Aug 22 21:18:15 CEST 2007


On 22 kol, 16:01, Gabriel Genellina <gagsl-... at yahoo.com.ar> wrote:
> On 22 ago, 10:04, vedrandeko... at v-programs.com wrote:
>
>
>
> > > >> > e.g I need run my my_scripts_setup.bat that contain:
>
> > > >> > python myscript_setup.py py2exe
>
> > > >> > Can I cover or redirect log of that process into my wx program?
> > > >> > I'am using Windows XP SP2, and Python 2.5.
>
> Try the subprocess module. For the single line command you posted
> earlier, you don't even need the bat file:
>
> import subprocess
> p = subprocess.Popen(["python", "myscript_setup.py", "py2exe"],
> stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
> p.wait()
> output_from_process = p.stdout.readlines()
>
> This would be fine if executing the script takes relatively a short
> time and doesn't generate so many output lines; there are other
> examples in the subprocess module documentation <http://
> docs.python.org/lib/module-subprocess.html>
>
> --
> Gabriel Genellina

Hi,

This works fine.
Thanks!




More information about the Python-list mailing list