argv[0] will contain the command line whatever it is - fully qualified or partially qualified. You'll need to correlate what you get from argv[0] with what you get from getpwd() to get a consistent output.
hth ty ----- Original Message ----- From: "Peter Rundle" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, November 06, 2002 11:27 AM Subject: [SLUG] Another 'C'ly question > 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 http://www.sold.com.au - SOLD.com.au - Find yourself a bargain! -- SLUG - Sydney Linux User's Group - http://slug.org.au/ More Info: http://lists.slug.org.au/listinfo/slug
