home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / perl / 5555 < prev    next >
Encoding:
Text File  |  1992-08-27  |  1.2 KB  |  34 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!ftpbox!mothost!merlin.dev.cdx.mot.com!fendahl.dev.cdx.mot.com!mcook
  3. From: mcook@fendahl.dev.cdx.mot.com (Michael Cook)
  4. Subject: Re: got a symlink checker/chaser for crontab?
  5. Message-ID: <mcook.714926334@fendahl.dev.cdx.mot.com>
  6. Sender: news@merlin.dev.cdx.mot.com (USENET News System)
  7. Nntp-Posting-Host: fendahl.dev.cdx.mot.com
  8. Organization: Motorola Codex, Canton, Massachusetts
  9. References: <17544@autodesk.COM>
  10. Date: Thu, 27 Aug 1992 14:38:54 GMT
  11. Lines: 21
  12.  
  13. dansmith@Autodesk.COM (Daniel Smith) writes:
  14.  
  15. >    Well... I basically want a script that will take
  16. >"find / -type l -print" and check the links to see if they resolve.  It's
  17. >something I'd run once a day out of crontab.  Rather than reinventing
  18. >what must be a somewhat common wheel, I thought I'd ask here first.
  19. >The script would produce a list of symlinks in need of updating/deletion,
  20. >which presumably would get piped into mail.
  21.  
  22. If it's an invalid symlink, you can lstat it, but you can't stat it.
  23.  
  24. while (<>)
  25. {
  26.     next unless lstat($_);
  27.     next unless -l _;
  28.     next if stat($_);
  29.     print "invalid symbolic link: $_ -> ",
  30.         (readlink($_) || "[can't readlink: $!]"), "\n";
  31. }
  32.  
  33. Michael.
  34.