I know my title is not descriptive so let me try to explain it here.
Normally I execute my python script like this:
D:\github\Miscellaneous-Programs\Python>python check.py -h
hello
['check.py', '-h']
Now what I did is added the folder D:\github\Miscellaneous-Programs\Python
in my windows path
environment variable. Than I tried to execute my script like this:
C:\Users\noob>check -h
hello
['D:\\github\\Miscellaneous-Programs\\Python\\check.py']
As you see it didn't showed the -h
argument I supplied to it.
My check.py
import sys
print "hello"
print sys.argv
If I remove print sys.argv
from the above mentioned python script it work fine in both cases I mentioned above i.e, it prints "hello" just fine.
So, my question is how does one execute a python script that accepts some command line arguments after the script is added to environment variable.
My purpose is to execute my python script
from anywhere in the windows command prompt which is somewhat similar to chmod +x check.py
.
I tried the chmod
option in cygwin it works fine for both cases.
Cygwin output
noob@noob-PC ~
$ chmod +x check.py
noob@noob-PC ~
$ ./check.py h
['./check.py', 'h']