help-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Determing intermediate symlinked name in a Bash script


From: Nate Bargmann
Subject: Determing intermediate symlinked name in a Bash script
Date: Mon, 22 Nov 2004 07:27:42 -0600
User-agent: Pan/0.14.2.91 (As She Crawled Across the Table (Debian GNU/Linux))

Hi.

I have an interesting little problem I am trying to solve.  I have a
script named 'junk' with links to it named 'foo' and 'bar'.  Using the
command basename $0 in the script correctly returns 'foo' or 'bar'
depending on which name was used to call the script (or 'junk' if called
directly).

However, I have another set of scripts that create a symlink and the name
of the symlink varies and it is indeterminate from the name of this
symlink how my called script should function.  So, now lets say that the
symlink named 'redirect' is pointing to 'foo' or 'bar' which in turn
points to the script 'junk':

redirect -> foo || bar -> junk

I want to figure out from inside the script 'junk' whether 'redirect'
points to 'foo' or 'bar' so 'junk' can take appropriate action.  The link
'redirect' is dynamic and it's name is unpredictable.  There must be some
way that the shell "knows" by following the symlinks whether 'foo' or
'bar' was in the chain.  How can I get to that information?

Thanks!

- Nate >>

-- 

"The optimist proclaims that we live in the best of all possible worlds,
the pessimist fears this is true."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]