I'm learning to use the subprocess module.
I'm trying to run a .bat script under subprocess. The .bat script writes to a file every time it's called by double-clicking, but won't write to the same file when called from subprocess.
It's similar to this question, but in my case I'd much rather adapt the caller python script then the callee .bat script. The .bat is what I'm about to test.
My code follows. Path and name altered for brevity.
import subprocess
p=subprocess.Popen(r"path\foo.bat", shell=True, stdin = subprocess.PIPE, stdout = subprocess.PIPE)
p.communicate(input='\r\n')
I will need to fill in user input as the .bat runs, so (I think) I need to call Popen directly rather than using convenience functions. But other than that direct call I think the issue is not related, because the file writing should occur before the .bat's first need for user input.
Ommitting the communicate call or each of the arguments to Popen were tried and failed.
How can I change my python script to give the .bat file-writing privileges?
The obvious security implications are not relevant to my use case, the .bat is trusted.
EDIT: when implementing Rptk99's suggestion I've noticed that I can replace the path to the .bat with any string (literally, I've tried "hjklhjilhjkl"), and I'll get the same behaviour: the python prompt becomes interactive again. So I have a more fundamental problem: I cannot see any errors returned from the call.