2

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?

asked Mar 12, 2013 at 22:41

2 Answers 2

3

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.

answered Mar 12, 2013 at 22:43
Sign up to request clarification or add additional context in comments.

1 Comment

That doesn't take care of the extension.
3

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 ./.

answered Mar 12, 2013 at 22:45

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.