Operating System - HP-UX
1753916 Members
8011 Online
108810 Solutions
New Discussion

Re: Symbolic Link issue where cd to path works fine, but ls to ame path fails.

 
HerrMueller
New Member

Symbolic Link issue where cd to path works fine, but ls to ame path fails.

I have created a symbolic link to a directory.

  • ln -s /tmp/data/testing /usr/appl/data/testing
  • If I cd /usr/appl/data
  • ls -l
  • testing -> /tmp/data/testing

This is correct and what I would expect. However this is my problem. There is a directory called /usr/appl/progs

  • I am in /tmp/data/testing and I "cd ../../../usr/appl/progs"
    • Everything works, I actually go to the /usr/appl/progs
    • However, If I am in /tmp/data/testing and I "ls ../../../usr/appl/progs", it fails (directory not found)

Any ideas?

Issue is there are pointer in the testing file to progs that cannot be seen. Changing the pointers to not use relative path would be insane.

2 REPLIES 2
Steven Schweda
Honored Contributor

Re: Symbolic Link issue where cd to path works fine, but ls to ame path fails.

> I have created a symbolic link to a directory.

   On what?

      uname -a

> o However, If I am in /tmp/data/testing and I
> "ls ../../../usr/appl/progs", it fails (directory not found)

   I constructed what looked to me like a replica environment, and saw
what was expected:

dyi# uname -a
HP-UX dyi B.11.31 U ia64 4235313755 unlimited-user license

dyi# mkdir -p /usr/appl/data/
dyi# mkdir -p /usr/appl/progs
dyi# touch /usr/appl/progs/u_a_p_file
dyi# mkdir -p /tmp/data/testing
dyi# ln -s /tmp/data/testing /usr/appl/data/testing

dyi# cd /usr/appl/data
dyi# ls -l
total 0
lrwxr-xr-x   1 root   sys   17 Apr 10 07:26 testing -> /tmp/data/testing

dyi# cd /tmp/data/testing
dyi# cd ../../../usr/appl/progs
dyi# pwd
/usr/appl/progs
dyi# ls -l
total 0
-rw-r--r--   1 root       sys              0 Apr 10 07:25 u_a_p_file

dyi# cd /tmp/data/testing
dyi# ls -l ../../../usr/appl/progs
total 0
-rw-r--r--   1 root       sys              0 Apr 10 07:25 u_a_p_file


   I'd look at all the directories in these trees to see if there are
unobvious symlinks or permission problems.


> [...] Changing the pointers to not use relative path would be insane.

   Perhaps, but creating a symlink with an absolute path can cause
trouble, too.

> ln -s /tmp/data/testing /usr/appl/data/testing

   If I use NFS on some other host, and I do something like:

      ls /net/your_host/usr/appl/data/testing

then I could end up looking at my own "/tmp/data/testing", not the one
on "your_host".  Generally safer:

      ln -s ../../../../tmp/data/testing /usr/appl/data/testing

Dennis Handly
Acclaimed Contributor

Re: Symbolic Link issue where cd to path works fine, but ls to ame path fails.

> If I am in /tmp/data/testing and I "ls ../../../usr/appl/progs", it fails (directory not found)

 

Not sure how that can fail if you're in /tmp/data/testing/ and not /usr/appl/data/testing/.

I.e. the former would have nothing to do with the symlink you mentioned.

You might try using "ll -id" on each path in ../../../usr/appl/progs to see what each has.