Subprocess in script doesn't work, when started manually it does

111 views Asked by At

I have a script that reads from an mssql database and passes the read data to a subprocess of some.exe. The data fetching works, fine but as soon as it is supposed to start proc = subprocess.(["C:\\absolute\\path\\some.exe ", fetched_data]) proc.wait() it seems to skip it and goes on for the next "fetched_data".. I also tried to use subprocess.call(["C:\\absolute\\path\\some.exe ", fetched_data])

If I start python in the console (windows cmd) and do the exact same thing it works.

Why does calling the subprocess in the script not work and if issued manually in the console it does?


edit: The problem was that the subprocess started in the script again used another.exe, which couldn't be found by the subprocess (as the it used the python path). When started from directory where some.exe and another.exe are, the script runs fine.

1

There are 1 answers

4
Don Question On BEST ANSWER

fetched_data is an additional argument therefore:

proc = subprocess.call(["C:\\absolute\\path\\some.exe ", fetched_data])

It's an argument LIST not a string, what subprocess expects.