On Mon, 28 Mar 2005 16:09:09 -0800, Jonathan Nichols <[EMAIL PROTECTED]> 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 > > -- > gentoo-user@gentoo.org mailing list > >
If you're comitted to using 'wget', you could add a few lines of code to perl to check for the '404 Not Found' response. Something like (FYI: I'm not a PERL expertise either): open(WGET, "wget xxxx |"); while (<WGET>) { if (~/404 Not Found/) { print "Couldn't get File" } } ... -Hani -- gentoo-user@gentoo.org mailing list