Call the right executable on *nix
January 12, 2017 · 1 minute to read · bash, Linux
One of several problems that occurs when you develop scripts is the selection of the right executable, for example usually with python, you can have three executables:
python (which points to one of previous).
The problem happens when you have to run your script:
- by using executable name on command line
- or with a shebang
With the last one, interpreter does not check the
PATH variable. Consequently, shebang needs to point to the right executable independently of underlying system. But on different Linux distributions,
python can change from version 2 to version 3. And how to deal with
Right solution must be to use
PATH variable like in interpreter to find the first matching executable. Fortunately, there is always a good solution on Linux. Here, it is the
So please, always use this when you will have to run scripts. It can save a lot of time for just a version problem.