Symbolic Links for Lunks.

root at MCIRPS2.MED.NYU.EDU root at MCIRPS2.MED.NYU.EDU
Wed Aug 8 07:12:17 AEST 1990


After having clobbered too many  very important files and directories that
I wanted to make local symlinks to, I wrote the script below to
make it more difficult for me to clobber my files with sgi symbolic
links. Use it in good health. I would be interested in your improvements too!

#! /bin/sh
# Less dangerious and more user frendly front end for ln -s .
# Prevents you from making symbolic linkages the wrong way and clobbering what
# you want to link to.

clear
# . Version.mac #a macro that records who and how often this is used.
file="$1"

echo "Enter existing file you wish create a link to"
if [ "$1" ]
then
echo "or enter a return to use $1"
fi

read file

        if [ -z "$file" ]
        then
        file=$1
        fi

        if [ -x $file ]
        then
        echo "GOOD. $file exists"
        ls -ld $file
        else
        echo "$file does not exist"
        echo " How do you expect me to make a link to a file I can't find."
        echo " bad bad boy"
        exit 1
        fi

echo "\n\n"

echo "Enter name of link to create $2"

        if [ -z "$2" ]
        then
        echo "or return to use `basename $file`"
        fi

read link

        if [ -z "$link" ]
        then
        link=$2
        fi

        if [ -z "$link" ]
        then
        link=`basename $file`
        echo "do you want me to use $link as your local link to \n$file ?"
        echo "\nReturn to continue,anything else aborts."
        read ans
                if [ -n "$ans" ]
                then
                exit 1
                fi
        fi

        if [ -x $link ]
        then
        echo "bad bad bad boy, $link exists. If you don't believe me, look"
        ls -ld $link
        exit 1
        else
        echo "nice kitty"
        echo " $link is ready to create"
        fi

ln -s $file $link
echo "\n\n"
ls -ld $file $link | cut -c1-10,40-

echo "$0 :Completed"
# . End.mac
exit 0

+-----------------------------------------------------------------------------+
| karron at nyu.edu                          Dan Karron                          |
| . . . . . . . . . . . . . .             New York University Medical Center  |
| 560 First Avenue           \ \    Pager <1> (212) 397 9330                  |
| New York, New York 10016    \**\        <2> 10896   <3> <your-number-here>  |
| (212) 340 5210               \**\__________________________________________ |
+-----------------------------------------------------------------------------+



More information about the Comp.sys.sgi mailing list