Reputation: 29
I have one python file (abc.py) which include several commands like make directory, copy commands. I want to execute it such like that,whenever I hit command for example abc --makedir on console, it should make directory. makedir is function which is written in abc.py.
Upvotes: 1
Views: 1916
Reputation: 26738
Rename abc.py
to abc
.
Make it executable:
chmod +x abc
Then add this at the first line of your script:
#!/usr/bin/python
From command line (if abc
is in python path):
#abc
To create a directory like you said , you should parse arguments passed to python script.
For example:
import sys
if len(sys.argv)>1:
if sys.argv[1] == '--makedir':
makedir()
For more informations Look at this link What's the best way to grab/parse command line arguments passed to a Python script?
Upvotes: 1