I know that my title is not descriptive, so let me try to explain it here.
I usually execute my python script as follows:
D:\github\Miscellaneous-Programs\Python>python check.py -h
hello
['check.py', '-h']
Now, what I have done is adding a folder D:\github\Miscellaneous-Programs\Pythonto my windows variable path. Than I tried to execute my script as follows:
C:\Users\noob>check -h
hello
['D:\\github\\Miscellaneous-Programs\\Python\\check.py']
As you can see, he did not show the argument -hthat I gave him.
My check.py
import sys
print "hello"
print sys.argv
If I remove the print sys.argvscript from the above python, it works fine in both cases that I mentioned above, then it prints "hello" perfectly.
So my question is how to execute a python script that takes some command line arguments after adding the script to the environment variable.
- python script Windows, chmod +x check.py.
chmod cygwin, .
Cygwin output
noob@noob-PC ~
$ chmod +x check.py
noob@noob-PC ~
$ ./check.py h
['./check.py', 'h']