Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: symlink destination



>>>>> "TM" == Tod McQuillin <devin@example.com> writes:

    TM> #!/bin/sh

    TM> file=/path/to/file
    TM> dest=`perl -e "print readlink(\"$file\");"`

    TM> (Actually this is a subtle hint that perl makes this kind of
    TM> scripting easier... but it will work in a shell script if you
    TM> have perl around.)  -- Tod McQuillin

I completely agree. From another hand, writing installation scripts in
sh looks more 'real-man-ish" :)

>>>>> "JM" == Jake Morrison <jacob.morrison@example.com> writes:

    JM> Uvator, There is a readlink(2) system call on HP/UX.

    JM> So.....

    JM> #include <unistd.h> #include <limits.h> #include <stdio.h>
 
    JM> int main(int argc, char** argv) { char buf[PATH_MAX + 1];
 
    JM>         if ( (argc < 2) || (!argv[1]) ) { fprintf(stderr, "%s:
    JM> usage: <symlink>\n", argv[0]); return 1; }
 
    JM>         if ( readlink(argv[1], buf, PATH_MAX) == -1) {
    JM> perror("readlink"); return 1; }
 
    JM>         printf("%s\n", buf);
 
    JM>         return 0; }

    JM> I can compile this for you on HP/UX 10.2 if you like.

Thank you, Jake, I can do it myself.

>>>>> "ASZ" == A Sajjad Zaidi <sajjad@example.com> writes:

    ASZ> 'file $symlink_name -b | cut -c 18-'

Thanks for the other replies too, it looks like fun.

Viktor


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links