redirect or cover .bat log

vedrandekovic at v-programs.com vedrandekovic at v-programs.com
Thu Aug 23 02:42:52 EDT 2007


On 22 kol, 21:18, vedrandeko... at v-programs.com wrote:
> 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!

Hi,

This,works fine except this last line:

 output_from_process = p.stdout.readlines()

I get an error:

p has not attribute stdout

Regards,
Vedran




More information about the Python-list mailing list