I have a script.py that I'd like to run when the user types "script" in unix. How do I accomplish this, instead of forcing him to type ./script.py each time?
2 Answers 2
You need to put the directory of the script in your PATH environment variable.
e.g.
/path/to/script.py
export PATH=$PATH:/path/to
To obviate typing the extension create a local symlink
ln -s /path/to/script.py /path/to/script
This prevents polluting /usr/local/bin with manual symlinks (which could be important on a multi-user) system.
1 Comment
You will need to add a symlink to the script, without using the .py extension, and place it somewhere on your system path. For instance, you might do
sudo ln -s myscript.py /usr/local/bin/myscript
Then you will need neither the .py nor the ./.