It is currently Sun, 21 Dec 2014 19:24:22 GMT



 
Author Message
 How to test softlinks to directories
I want to test a softlink within a directory on whether it points to a real
directory or a non-existant directory. For example:

% ls -ld  /home/work_dev/db/build5/sproc/common/SCCS
                                  --> /net/DEV_SCCS/sproc/common

How can i tell if /net/DEV_SCCS/sproc/common really exist?
I tried something like this in my c-shell script. However, the result is not
what I expect. References to non-existant softlinked directories are being
written to my out_file.

...
cd /home/work_dev/db/build5/sproc/common
if ( -d SCCS ) then
    execute cmd
endif

but this doesn't seem to work nor does

...
cd /home/work_dev/db/build5/sproc/common
if ( -f SCCS ) then
    execute cmd
endif

This is a c-shell script..... please don't give me a sh or ksh solutions...
:-)

--
 kevin



 Mon, 30 Jul 2001 03:00:00 GMT   
 How to test softlinks to directories
: I want to test a softlink within a directory on whether it points to a real
: directory or a non-existant directory. For example:

: % ls -ld  /home/work_dev/db/build5/sproc/common/SCCS
:                                   --> /net/DEV_SCCS/sproc/common

: How can i tell if /net/DEV_SCCS/sproc/common really exist?
: I tried something like this in my c-shell script. However, the result is not
: what I expect. References to non-existant softlinked directories are being
: written to my out_file.

: ...
: cd /home/work_dev/db/build5/sproc/common
: if ( -d SCCS ) then
:     execute cmd
: endif

: but this doesn't seem to work nor does

: ...
: cd /home/work_dev/db/build5/sproc/common
: if ( -f SCCS ) then
:     execute cmd
: endif

: This is a c-shell script..... please don't give me a sh or ksh solutions...
: :-)

This is a little test script.  The key is to look for <symlink>/. which
evaluates the symlink (unfortunately, it doesn't work for non-directories).

  #!/bin/csh
  ln -s /tmp/foo bar
  # test when non-existant
  if ( -d /tmp/bar/. ) then
    echo Is a dir
  else
    echo Is not a dir
  endif
  # test when file
  touch foo
  if ( -d /tmp/bar/. ) then
    echo Is a dir
  else
    echo Is not a dir
  endif
  rm foo
  # test when directory
  mkdir foo
  if ( -d /tmp/bar/. ) then
    echo Is a dir
  else
    echo Is not a dir
  endif
  rmdir foo
  rm bar

This is also useful with ls.

  -Arcege



 Tue, 31 Jul 2001 03:00:00 GMT   
 
   [ 2 post ] 

Similar Threads

1. Deleting a directory softlink

2. test test test test test test test

3. test test test test

4. softlinks when downloading redhat 5.1

5. downloading REDHAT 5.1 (what about the softlinks?)

6. NFS server problems (due to softlinks?)

7. Missing Softlinks

8. softlinks

9. problem creating softlink on automounted volume

10. showing softlinks in PATH


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software