Results 1 to 4 of 4

Thread: Broken directory?

  1. #1

    Default Broken directory?

    Hi,
    I have an odd problem which I suspect is of my own making. My /usr/bin directory has within it a single directory named X11. What is odd is that directory in turn has an another X11 directory to a depth of 41. I am able to use "cd" to position to the X11 directories, but, for some reason, I am unable to position to any of them using a simple Perl script that codes -
    chdir "/usr/bin/X11" || die "Failed to chdir to X11 $!";
    chomp($currdir = `pwd`);
    print "Current directory = $currdir\n";
    The result here is "Current directory = /usr/bin".
    I would certainly appreciate any suggestions.
    S660117

  2. #2

    Default Re: Broken directory?

    I am running Suse 11.1 on a Dell PC. Suse is 64 bit. Perl is v5.10.0 built for x86_64-linux-thread-multi

  3. #3
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: Broken directory?

    A look at the directory with ls -l would have revealed the reason instantly:

    lrwxrwxrwx 1 root root 1 2009-12-21 17:23 /usr/bin/X11 -> .

    /usr/bin/X11 is just a symlink to /usr/bin. So, if you want to deal with this problem in your script, it has to be more comprehensive. Either you do the chdir and accept the result, or if you wish to prohibit symlinks you have to check that it's not a symlink first. Depends on what you are trying to do.

  4. #4

    Default Re: Broken directory?

    ken_yap,
    Ok, I see now. I guess I need to exclude symlinks in my script - !(-l "$dirent").
    Thanks for your answer,
    s660117

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •