On Mon, 28 Mar 2005, Jonathan Nichols wrote:

> (Note: I suck at Perl.)
>
> I have a script. it's a simple script.
>
> #!/usr/bin/perl
> $file = "foo.txt";
> system"wget http://clutter.pbp.net/~jnichols/foo.txt"; || die "Couldn't
> get $file";
>
> Currently "foo.txt" doesn't exist. It'll return a 404. It doesn't die
> with the error message above. Basically, I need wget to die and return
> the specified error message if the result is *anything* but successful.
> If wget gets the file, ok. If it fails to get the file for any reason,
> barf out.
>
> Sounds simple enough, eh? I can't seem to find documentation on how to
> achieve this goal. Help? :P

The problem is that if the HTTP request fails, you will always get a file
even if it contains an error message. The only error this would catch is
if the connection failed for some reason, otherwise you will get 404 or
similar error codes.

It might be better to use a CPAN module that understands HTTP to do this.


-- 

--
[email protected] mailing list

Reply via email to