7

I would like to pass the contents of a file along with some other parameters to a python script on windows.

On linux, I can do it like this:

less input.txt | my_script.py  > output.txt

On windows I tried the following but it doesn't seem to work:

more input.txt | python my_script.py  > output.txt

Any idea what I'm doing wrong?

Pat Mustard
  • 1,852
  • 9
  • 31
  • 58

1 Answers1

13

Use following command. It works both in Linux and Windows.

python my_script.py < input.txt > output.txt
falsetru
  • 357,413
  • 63
  • 732
  • 636
  • 2
    For anyone concerned: the contents of the file is accessible via sys.stdin rather than sys.argv[n]. See here: http://stackoverflow.com/questions/13581632/using-textfile-as-stdin-in-python-under-windows-7 – Pat Mustard Jul 16 '13 at 02:03