How can I get path/name of the softlink to my python script when executing it
Saravanan Shanmugham (sarvi)
sarvi at cisco.com
Sun Apr 19 23:55:46 CEST 2009
Sorry. I should have responded earlier to close this thread. It was my programming error.
Both sys.argv and __file__ do point to the name and path of the softlink and not the actual program it is linked to.
So. Soryy. My bad programming got in my way.
From: Pascal Chambon [mailto:chambon.pascal at wanadoo.fr]
Sent: Sunday, April 19, 2009 2:36 PM
To: Saravanan Shanmugham (sarvi)
Cc: python-list at python.org
Subject: Re: How can I get path/name of the softlink to my python script when executing it
I fear that in this case the whole indirection operations on softlink occur only in the shell, and that the final command is only executed as if it were called directly on the real file...
Have you tried typing "python ./waf", to see how the resolution occurs in that case ?
Saravanan Shanmugham (sarvi) a écrit :
I am writiing a script say "wabexec" in python
I will then have softlinks from other softlinks like ls, waf,hello, etc that are in the same directory and pointing to wabexec.
When some executes ./waf or ./hello and wabexec gets invoked because of the softlink, how do I find out from within wabexec how it was invoked? was it throug waf or hello, etc.
both __file__ and sys.arg0 seem to have wabexec not the name of the softlink.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list