I am working on Mac OS X and I have a Python script which is going to be called by other scripts and programs (Apple's launchd in particular). I could call it with
python /Users/xyz/long/absolute/path/to/script.py arg1 arg2
Since the location of the script might change, I want to decouple other scripts and the launchd configuration files from the actual location, so that a call to the script looks like
script arg1 arg2
Defining an alias for Bash in $HOME/.bash_profile does not work, since launchd does not know about the alias.
What is the best way to define a "sytem-wide alias" or something equivalent?
I usually make a symbolic link and put it in /usr/bin (assuming /usr/bin is part of your PATH)
(In a terminal. You may have to use sudo ln -s depending on the permissions.
ln -s /Users/xyz/long/absolute/path/to/script.py /usr/bin/script.py
If you take Rory's advice and put the #!/usr/bin/python at the beginning of the script, you'll also need to make the script executable.
chmod a+x /Users/xyz/long/absolute/path/to/script.py
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With