0: #!/usr/bin/perl
1: # File to check
2: $fileToCheck = @ARGV[0];
3: print "Check HTTP File\n";
4: # Create an agent
5: use LWP::UserAgent;
6: $ua = new LWP::UserAgent;
7: $ua->agent("PerlMonks Webbot /1.1.1" . $ua->agent);
8:
9: # Create a request
10: my $req = new HTTP::Request HEAD => $fileToCheck;
11:
12: # Pass request to the user agent and get a response back
13: my $res = $ua->request($req);
14: if ($res->is_success) {
15: print "file $fileToCheck exists\n";
16: } else {
17: print "file $fileToCheck doesn't exist\n";
18: }
19: exit;
In reply to Check HTTP File (Header) by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |