Abolute path of argv[0]

From: Alvin (replay_at_to_the_newsgroup.thanks)
Date: 11/11/05


Date: Fri, 11 Nov 2005 14:02:19 GMT

Hello all,

I have a program that launches from the symlink:

   /usr/local/bin/app -> /opt/MyProgram/app

What I would like to do, is have the program, app, determine that its been
launched from a symlink then to change the CWD to /opt/MyProgram.

I'm using stat(2) and the S_IFLNK flag, which works if I run the program
as /usr/local/bin/app

My problem is that /usr/local/bin is in my $PATH. Therefore, if I run the
program "app" from any directory, say $HOME, argv[0] only contains "app"
not /usr/local/bin/app.

Is there a system call that can expand argv[0] to its absolute path?

Thanks,

Alvin



Relevant Pages

  • Re: Abolute path of argv[0]
    ... > I have a program that launches from the symlink: ... > What I would like to do, is have the program, app, determine that its been ... There is no good reason to do ...
    (comp.os.linux.development.apps)
  • Re: bash: relative to absolute path
    ... > I often need to get the absolute path of a file in my bash scripts. ... Does anyone have a more efficient/better solution? ... Note that if $1 is a symlink, the output is still a symlink. ...
    (comp.unix.programmer)
  • Re: [kde-linux] how to create relative path symlinks from konqueror?
    ... symlink with absolute path is created. ... just drag. ... 'link here' will be a symlink. ... Archives: http://lists.kde.org/. ...
    (KDE)
  • Re: how to use ^UP^/ from DCL ?
    ... the posix root is one level up of mnt, ... absolute path was wrong, bash would not have found the file ... BTW I found how to create symlink to a file. ...
    (comp.os.vms)
  • Re: Question on cp and links.
    ... Markus Becker wrote: ... Depends on the symlink (absolute path vs. relative path). ... broken link for /u2/bin/bar. ...
    (comp.os.linux.misc)