I have a program in python 2.7 and I cannot seem to run it in command prompt on Windows XP using a redirected input. I’m trying to do something like:
C:\>python foo.py < input.txt
but nothing works. I’ve tried using <& variations along with leaving off the explicit call to python.exe.
I’ve tried variations of piping as well, but nothing seems to work.
I can run python programs from command prompt and parse argument inputs just fine. The problem is that I can’t make one of those arguments be input from a simple .txt file.
Thanks in advance.
The problem is not with how you are running it from the command line, but rather how you have argparse set up in your script. You are definitely redirecting the file properly to stdin.
input.txt
foo.py
Output