I have the following batch file (test.bat)
my.py < commands.txt
my.py does the following:
import sys print sys.stdin.readlines()
Everything works fine if I run this batch file from the command line (from the cmd.exe shell on Windows 7).
But if I try to run it using the subprocess.call function from python, this will not work.
How I try to run it from python:
import subprocess import os
And this is the error message I get:
>my.py 0<commands.txt Traceback (most recent call last): File "C:\Users\.....\my.py ", line 3, in <module> print sys.stdin.readlines() IOError: [Errno 9] Bad file descriptor 1
I am using python 2.7.2, but on 2.7.5 I get the same behavior.
Any ideas?
source share