0

I am trying to automate running of a program with Popen in Python (2.7 on windows XP).

The program (a FORTRAN compiled executable that takes in user input through command line) runs fine when called manually through command prompt. But starts hanging when I try the following through python :

p = Popen(["cmd","/C", "abcd.exe"], stdout=PIPE)

The CLI prompt from the exe pops up for couple of milliseconds and closes when I try to run it directly:

p = Popen("abcd.exe",stdout=PIPE)

Why this is happening?

jfs
  • 399,953
  • 195
  • 994
  • 1,670
Ash Sharma
  • 470
  • 3
  • 18
  • Perhaps, `abcd.exe` can't be found in the second case: `cmd` and `CreateProcess()` (used by `Popen()` on Windows) use [different algorithms to find the executable](http://stackoverflow.com/a/25167402/4279). Does providing the full path to `abcd.exe` fixes the issue? (start the scripts in the console (Win+R `cmd`), to see the output/errors) – jfs Feb 13 '16 at 14:14
  • Thank you for the reply.! The program abcd.exe was in the same folder as the python script. It turns out that the FORTRAN executable (with some JAVA wrapper) was actually not letting me read the output. It was sorted when I was able to access the exec without a wrapper. Hope I am making sense here. – Ash Sharma Mar 17 '16 at 05:20

0 Answers0