Search code examples
linuxperlpath

How to make a programme executable anywhere in the SHELL


How to make a programme executable in the SHELL

I have git cloned a number of tools into my HOME folder. Now as there are many of them and my query files are located on a different directory, what I need is make a programme executable from everywhere in the SHELL. I have read this thread but how about Perl and Python scipts. For example, I have a script.pl or script.py file in a folder named scrips. What should I do to make that script run from everywhere?


Solution

    1. Make the scripts executable: chmod +x $HOME/scrips/* This needs to be done only once.
    2. Add the directory containing the scripts to the PATH variable: export PATH=$HOME/scrips/:$PATH (Verify the result with echo $PATH.) The export command needs to be run in every shell session. For convenience, you want to add that command to the $HOME/.profile file so it is run automatically for you at log-in time.

    Now you can execute script.pl some-arguments or script.py some-arguments from anywhere.