Armed Polite Society
Main Forums => The Roundtable => Topic started by: AZRedhawk44 on April 02, 2009, 09:22:18 PM
-
Got me a problem:
I've got a link file that I need to figure out where the real target is located.
How do I do that? I've tried readlink, but can't seem to get that to work.
Imagine you have:
/home/azredhawk44/somefile.txt
and
/home/azredhawk44/somefile.lnk
Whenever you vi, cat, more, etc against somefile.lnk... you end up in somefile.txt. Problem is, my situation is more difficult, because the link is running off somewhere else.
I've got a legacy informix app I'm rewriting to be straight MS SQL, but gotta support the existing crap until then. Totally stumped on how to trace down the original source code and make environment for one client's custom module that was written before my arrival with no documentation/source. Got a symlink taking me to a script that runs make, but it's erroring. Good fun. This particular environment is HP-UX.
-
Well the output isn't as clean as readlink, but how about ls -l? Or file -b?
-
ls -l will do it with the GNU filetools package and on my OS X laptop.
-
ls -l somefile.lnk
output only gives me:
-rw-r--r-- 2 azredhawk44 azredhawk44 18 2009-04-02 17:52 somefile.lnk
This doesn't tell me that it is targeted to somefile.txt in the same directory.
Moar plz.
-
file -b somefile.lnk
returns
ASCII text
which is the type of data in my test symlink (to somefile.txt).
I need something that reports /home/azredhawk44/somefile.lnk points to ./somefile.txt
-
Hard to test for me, the only symlinks I have point to dirs, but so you can see what I get:
patrick@patrick-ubuntu:~/ushare$ readlink Anime
/media/Tertiary/Anime
patrick@patrick-ubuntu:~/ushare$ ls -l Anime
lrwxrwxrwx 1 patrick patrick 21 2009-02-04 20:25 Anime -> /media/Tertiary/Anime
patrick@patrick-ubuntu:~/ushare$ file -b Anime
symbolic link to `/media/Tertiary/Anime'
-
Hang on a second, I was assuming you were talking about symlinks created in a Unix environment. .lnk is a Windows shorcut.
http://www.linuxforums.org/forum/misc/126912-converting-windows-shortcuts-into-linux-links.html
The above link looks promising, but is there any way you can just get the lnks on a Windows box? Would probably be easiest to get them all on a VM and right click in a windows guest to see the properties.
-
are you sure it's a symlink and not a hardlink?
ls -i firstfile
ls -i secondfile
If its a hardlink, you'll see something like this:
asthma:3:~$ touch foo
asthma:3:~$ ln foo bar
asthma:3:~$ ls -i foo bar
1994986 bar 1994986 foo
asthma:3:~$
Where the inode numbers reported are teh same.
Hardlinks work only on the same filesystem.
-
Sorry... I'm many moons removed from unix practice.
Yeah, could be a hardlink rather than symlink.
Looks that way:
ls -i somefile*
8896670 somefile.lnk 8896670 somefile.txt
And it's not linking a directory... it's linking to a script that runs a make command. I need to browse the actual script's folder for missing dependencies but I can't find it... All I've got is a .link file. And it is a 4-letter extension, "link."
I don't have access to it right now and won't until tomorrow again. I've been toying with a txt file and linked file to it.
So... how do I read a hardlink's properties?
Can I search for a specific inode and get a list of all hardlinks to it?
-
find -inum 8896670
results:
./test.txt
./test.lnk
Or:
find -samefile test.lnk
results:
./test.txt
./test.lnk
Hooray. Thanks, guys.
Hopefully "find" exists on HP-UX and isn't GNU-only.
ETA: Yep, it exists. -inum switch is common between the two, but -samefile doesn't seem to be.
-
I guess I need to ask:
Why not just use the "link" for whatever you are doing?
* "link" in quotes because if it really is a hardlink, then there's really no "real" and "linked" file, they are the same.
-
Because it isn't as simple as a linked text file in the same parent directory.
It's a compile script, linked from one directory like this:
/product/source/product_name.link
to another, somewhere else unknown, like this:
/product/someotherdir/somefile.sh
I've got missing dependency error messages and I need to know the location of "someotherdir."
Basically, I've inherited 15 year old code that I have to reverse engineer. I've got the actual source on a piece of paper in front of me... but no lists of dependencies or compile instructions.
And I've made a change to the source since it wasn't working as the firm wanted, and now have to recompile.
I'd love to re-write it as a straight SQL to SQL query, but their target DB is still Informix. So I can't.
-
OIC. You needed the location of the other file, not the file (contents) itself.
-
Basically, I've inherited 15 year old code that I have to reverse engineer. I've got the actual source on a piece of paper in front of me... but no lists of dependencies or compile instructions.
And I've made a change to the source since it wasn't working as the firm wanted, and now have to recompile.
I'd love to re-write it as a straight SQL to SQL query, but their target DB is still Informix. So I can't.
Eww, that really sucks. :|
I have a similar situation. My workplace has a totally undocumented .exe that does some data manipulation. No source, no requirements, no help file... Just an x86 exe. I get: "Can you change this to make it do xxx?"
-
This is the kind of Male Bovine Excrement I deal with daily. You wouldn't believe some of the things I've been asked.
My favorite so far:
"Can we put our swap on a ramdisk to increase performance??"
We really need a "headdesk" emoticon.
-
head desk: http://www.deviantart.com/#catpath=customization/icons/emoticons&order=9&q=head+desk
There are some facepalm emoticons over there, but they don't turn out well in normal-sized emoticons.
My workplace has a totally undocumented .exe that does some data manipulation. No source, no requirements, no help file... Just an x86 exe. I get: "Can you change this to make it do xxx?"
Only one thing to do... rewrite it in intercal so that once you're gone they're stuck maintaining it in that language :)