Martin R Morales wrote: > Good Morning/Afternoon Everyone, > > I have been reading up on LWP::UserAgent and HTTP::Request of the LWP package. > This is good stuff. > But I am still confused about a couple of things. Here is ther senario. I have > a file I want to download from > my server and I can do that with LWP. But what I'm confused on is One: how do > I save the file to a certain > directory
That is not exactly the question at this point, because the response received does not constitute a file while in transit. When LWP::UserAgent receives a response, it puts it into an HTTP::Response object This object provides te method content() to get the returned html. The request method, though, does provide a means to automatically store this data to file. The scond parameter of request can be a string scalar, in which case the module uses this string as the filename to save the data to. The specific directory that you want to store this data in is just part of the filename. > once I have started the GET process; insted of it dumping to stdout? Does LWP::UserAgent dump to STDOUT? I don't think so. The get and request methods both return response objects, which the calling script can query and print to STDOUT. > The other part I am unclear on > is this: if the site does not contain the file I am looking to GET, then I > should receive the standard web response > of 'file does not exist' or other responses like 'forbidden', etc. I am > unclear how to 'log' these responses or redirect > them to a file for later examination insted of dumping to stdout. Like this: Greetings! E:\d_drive\perlStuff>perl -MLWP::UserAgent my $ua = LWP::UserAgent->new; my $request = HTTP::Request->new('GET', 'http://www.isp.org/~some_user/missing_page.htm'); my $response = $ua->request($request); print $response->content; ^Z <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML><HEAD> <TITLE>404 Not Found</TITLE> </HEAD><BODY> <H1>Not Found</H1> The requested URL /~some_user/missing_page.htm was not found on this server.<P> <HR> <ADDRESS>Apache/1.3.26 Server at members.isp.org Port 80</ADDRESS> </BODY></HTML> HTH, Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>