If I have a python script that is executed via a symbolic link, is there a way I can find the path to the script and not the symbolic link? I tried using the methods suggested in this question, but they always return the path to the symbolic link, not the script.
For example, when it is saved as "/usr/home/philboltt/scripts/test.py":
#!/usr/bin/python import sys print sys.argv[0] print __file__
and I create this symbolic link
ln -s /usr/home/philboltt/scripts/test.py /usr/home/philboltt/test
and execute the script using
/usr/home/philboltt/test
I get the following output:
/usr/home/philboltt/test /usr/home/philboltt/test
Thanks! Phil
source share