Re: symbolic link problem
- From: Glenn Jackman <glennj@xxxxxx>
- Date: 24 Jun 2008 13:52:34 GMT
At 2008-06-24 08:26AM, "Eric Hassold" wrote:
So, to detect a broken link, you may use:
I can't resist commenting on this proc.
proc brokenlink {f} {
if {![catch {file type $f} ftype]} {
[file type] will only throw an error if $f does not exist (as far as I
know). I think that's something the caller would want to know, so I'd
let that error propagate up.
if {$ftype eq "link" && ![file exists $f]} {
You probably meant to use [file exists [file readlink $f]] there
return 1
}
}
return 0
}
How about:
proc is_broken {linkname} {
return [expr { ! [file exists [file readlink $linkname]]]
}
It will error if $linkname does not exist or is not a link file, so:
set rc [catch {is_broken $filename} result]
if {$rc == 0 && $result} {
puts "$filename is a broken link"
} elseif {$rc == 0} {
puts "link $filename is OK"
} else {
puts "not a link: $result"
}
--
Glenn Jackman
Write a wise saying and your name will live forever. -- Anonymous
.
- Follow-Ups:
- Re: symbolic link problem
- From: Larry W. Virden
- Re: symbolic link problem
- References:
- symbolic link problem
- From: j . lewandowski
- Re: symbolic link problem
- From: Eric Hassold
- symbolic link problem
- Prev by Date: Re: http::get in web page hangs server
- Next by Date: closing a connection with Httpd_ReturnData
- Previous by thread: Re: symbolic link problem
- Next by thread: Re: symbolic link problem
- Index(es):
Relevant Pages
|