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