0

I executed this code in python: (test.py)

from subprocess import Popen
p = Popen("file.bat").wait()

Here is file.bat:

@echo off
start c:\python27\python.exe C:\Test\p1.py %*
start c:\python27\python.exe C:\Test\p2.py %*
pause

Here is p1.py:

This line is error
print "Hello word"

p2.py is not interesting

I want to know the exception(not only compiling error) in p1.py by running test.py? How can I do this?

Thanks!

shira stenmetz
  • 297
  • 1
  • 6
  • 11

1 Answers1

0

Here's how I got it working: test.py

from subprocess import Popen
p = Popen(["./file.sh"]).wait()

Make sure to add the [] around file, as well as the ./. You can also add arguments, like so: ["./file.sh", "someArg"] Note that I am not on Windows, but this fixed it on Ubuntu. Please comment if you are still having issues

EDIT: I think the real solution is: Using subprocess to run Python script on Windows

This way you can run a python script from python, while still using Popen

Community
  • 1
  • 1
Cade Brown
  • 165
  • 2
  • 8