Here is a short method to check if a web page exists from a perl script,
this script will test the existense of a page and do something as a result:
#!/usr/bin/perl
use LWP::Simple;
print “Content-Type: text/html\n\n”;$url = “http://site.com/“;
if (head($url)) {
# ok document exists
print “OK: found $url”;
} else {
# something is not well
print “PROBLEM: $url is missing”;
}
This script is using the libwww-perl package.
Related posts:
T.R. says:
I would probably extend it to check the returned error code as well.
For getting a response doesn’t necessarily mean that all is well. It can be a redirect command or possibly some other type of error. Would you also like to follow a chain of redirects? (you should detect and avert cyclic redirects).
One more question I’d be curious to know is whether LWP supports HTTPS protocol as well?
yonitg says:
Thanks T.R. – I’ll look at adding more functions to the script later on,
welcome to my new blog
jmixx says:
Did you ever update this? I just had a need for this kind of script today…
yonitg says:
@jmixx – this is not updated yet – but i will this week
trongtran.javadev says:
for linux
if [ -z $SVN_URL ]; then
for window
don’t known