Linux application deployment
Jarek Zgoda
jzgoda at gazeta.usun.pl
Sun Sep 5 13:10:10 EDT 2004
Grant Edwards <grante at visi.com> pisze:
>> import sys, os
>>
>> me = os.path.abspath(sys.argv[0])
>
> That's only mostly reliable. Nothing in Linux/Unix actually requires that
> argv[0] be the program's path. It is the convention to pass that as
> argv[0], but there may be corner cases where it doesn't work.
Based on Python docs:
"""
argv
The list of command line arguments passed to a Python script.
argv[0] is the script name (it is operating system dependent whether
this is a full pathname or not). If the command was executed using
the -c command line option to the interpreter, argv[0] is set to the
string '-c'. If no script name was passed to the Python interpreter,
argv has zero length.
"""
http://docs.python.org/lib/module-sys.html
In my opinion, this would be enough to get full path of currently
running program, if run from script. Are there any caveats (except this
"-c" option, which I don't count, as is not relevant in most cases)?
--
Jarek Zgoda
http://jpa.berlios.de/
More information about the Python-list
mailing list