Eldan Aranye has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I was using symlink on one of the codes that I was supposed to integrate to Galaxy. It worked perfectly fine in the previous codes that I have been doing, but now it fails to do its job. Can anyone tell me some reasons why symlink creates broken links? I'm sure the paths that I am using are correct. Thanks!

Replies are listed 'Best First'.
Re: Problem with symlink
by cheekuperl (Monk) on Jun 18, 2012 at 03:36 UTC
    Removing the original file creates "broken links". The symlink file only contains the path of original file used while creating the link.
    In the following example, the size of symlink is only 8 bytes.
    $ cat > orig.txt This is original file $ ln -s orig.txt lnk $ ls -ltr orig* lnk* -rw-r--r-- 1 vaibhav grp 22 Jun 17 22:31 orig.txt lrwxrwxrwx 1 vaibhav grp 8 Jun 17 22:32 lnk -> orig.txt $ cat lnk This is original file $ rm orig.txt $ ls -ltr orig* lnk* orig*: No such file or directory lrwxrwxrwx 1 vaibhav grp 8 Jun 17 22:32 lnk -> orig.txt $ cat lnk cat: cannot open lnk $

      Thanks for that. I have another question. Imagine this:

      I have a perl script that symlinks file A to file B in another location. I then use file B as input for another program. I did not delete file A, and I did not do any modifications on it, so I'm assuming there is no broken link. But then the program tells me that file B's empty. Has anyone encountered this problem before?

      Thanks in advance for any help!

        You've created link A to orig file B. It looks like:
        /path1/A -> /path2/B
        As per your statements, A is untouched. B is passed to another program. Is there any chance B has been modified?
        Did you verify the permissions on B?
        Because I can't think of any other scenario that would cause B to go empty.
        Note that A will still have non zero size (since it contains path of B).