Reputation: 1371
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?
Upvotes: 2
Views: 179
Reputation: 10927
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.
Upvotes: 3
Reputation: 2885
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 ./
.
Upvotes: 3