Sluggers,

Coding a 'C' routine I need to know at execute time, the
full path that the program is being executed from.

In shell this is in $0 and is expanded at runtime even if
the program is found via the $PATH variable, I.e

echo $0 will always contain the full path to the program.

In C argv[0] contains the program name but it is not
expanded, I.E

  $ myprog

executes the program in /usr/bin but argv[0] only contains
"myprog", where as with

  $ /usr/bin/myprog

argv[0] contains "/usr/bin/myprog" and I can strip it to
get the path "/usr/bin" which is what I want.

Any suggestions / cluesticks?

TIA's

Pete

--
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to