Wednesday 28 August 2013

Python arguments cuts at < when reading from command line

Python arguments cuts at < when reading from command line

I got a script that is supposed to take the time it takes to execute a
python-script. For simplicity I just supply the actual command I want to
execute as arguments in the commandline.
Say I call:
python time.py python ratatosk.py < input.txt
Here everything after python time.py is the actual command I want to execute.
However, when reading the sys.argv with this:
print 'Number of arguments:', len(sys.argv), 'arguments.'
print 'Argument List:', str(sys.argv)
It only returns:
Number of arguments: 3 arguments.
Argument List: ['time.py', 'python', 'ratatosk.py']
Where did the rest of the arguments go? It looks like < somehow stripped
it away.
I am running Python Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012,
20:52:43) on a MacBook Pro.

No comments:

Post a Comment