On 9/12/07, Stewart Stremler <[EMAIL PROTECTED]> wrote:
> begin quoting Chuck Esterbrook as of Wed, Sep 12, 2007 at 04:55:11PM -0700:
> > On 9/12/07, Christopher Smith <[EMAIL PROTECTED]> wrote:
> > > Chuck Esterbrook wrote:
> > > > Let's say I have a script at /usr/bin/foo which is really just a link
> > > > to /usr/local/blah/bin/foo
> > > >
> > > > When I type "foo" at the command prompt (say bash), I would like the
> > > > foo script to know where it's really homed at. However, "dirname $0"
> > > > in that script will give "/usr/bin" instead of "/usr/local/blah/bin".
> > > >
> > > > Is there a way for a script to find out where it's really located?
> > > >
> > > man realpath
> >
> > Thanks, but that's C and I'm in bash. I could write up a little
> > utility, but I poked around more and found "readlink" which does the
> > trick.
>
> It's C?
Yep, it's C.
man realpath:
---
REALPATH(3) Linux Programmer's Manual REALPATH(3)
NAME
realpath - return the canonicalized absolute pathname
SYNOPSIS
#include <limits.h>
#include <stdlib.h>
char *realpath(const char *path, char *resolved_path);
---
$ realpath
-bash: realpath: command not found
I get the same thing on the latest Mac OS X.
"readlink" works from bash on both systems.
I could upgrade the boxes, but this script is for external users and
"readlink" appears ubiquitous.
-Chuck
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg