Re: Curious Symlink question
by Roy Johnson (Monsignor) on May 02, 2005 at 22:56 UTC
|
| [reply] |
|
Roy,
Yes, precisely. I wondered if there was a way for a file to know what symlink was originally.
I thought maybe it got passed along or something.
Sigh, I guessed not, but one can hope.
| [reply] |
|
| [reply] [d/l] |
|
You can, if you want the symlink used to start the Perl script currently being executed. It's in $0.
| [reply] |
Re: Curious Symlink question
by eibwen (Friar) on May 02, 2005 at 22:45 UTC
|
Your post is a bit difficult to follow, but $0 will return the name of the code as invoked. To illustrate:
$ echo "#!/usr/bin/perl\nprint $0;" > tmp
$ ln -s tmp temp
$ ./temp
./temp
UPDATE: Beware potential shell interpolation of $0. The ./tmp file should contain the follow two lines:
#!/usr/bin/perl -w
print $0
| [reply] [d/l] [select] |
|
yes! brilliant. the $0 var worked just as you guys described.
Sorry my question was confusing. Even apparently to myself.
Thanks for your help, and if you want here is the longer story.
Oracle applications 10.7 provides a way to feed arguments from oracle apps to a shell script.
It works like this
1. Make your shell script with a .prog extenstion. so test.prog
2. make a symlink to a special oracle binary like so using the name of your .prog so:
ln -s fnddescr test
then define test in oracle.
you call test from oracle, give it your arguments, and then oracle calls test which calls fnddescr which parses the oracle payload, and hands the arguments back to test.prog.
we wanted to know if how fnddescr could know what called it.
presumably they have something similiar to $0
again thanks for your help!
| [reply] |
Re: Curious Symlink question
by tlm (Prior) on May 02, 2005 at 23:43 UTC
|
| [reply] |
Re: Curious Symlink question
by cbrandtbuffalo (Deacon) on May 03, 2005 at 11:46 UTC
|
The brute-force approach would be to search your entire file system with something like merlyn's Find out where symlinks point, and find all the symlinks that expand to the original path you're looking for. Then you know who points to the original script. This would be feasible if you just needed to know at a point in time. Of course you probably wouldn't want to run it often. | [reply] |