I have written a bash script in MAC , which is placed in a directory say xyz.
Now i have a python file in the same directory xyz
We can also say that this python script will always be in the directory where this bash script is
So i want this bash script to be general
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 /Users/labuser/Desktop/Installer/OpenURL_GenericNotification.py Some Arguments
So i want to replace
so that from wherever this script is run python script is automatically calculated by some system variable like $cd
/Users/labuser/Desktop/Installer/ this like $cd in windows not sure how in MAC
Any comments on how to go about this script ??
In a Bash script, the path to the script is stored in the
dirname command returns the directory portion of a path (filename removed).
You can use the
$0 to get the script's base directory, and
cd to that path, and then run the Python script in the current directory:
cd "$(dirname "$0")" ./OpenURL_GenericNotification.py