Prev: FAQ 1.13 Is it a Perl program or a Perl script?
Next: FAQ 4.14 How can I compare two dates and find the difference?
From: E.D.G. on 26 Jun 2010 01:12 DOWNLOADING And PRINTING WEB SITE FILES QUESTIONS I am running a recent version of the ActiveState Perl program with Windows XP and Vista operating systems. The LWP module has been installed. Could someone list the correct Perl code to use for having a Perl program download and store or print a file from a Web site? I read all of the online documentation I could locate and tried various commands. However, error messages keep appearing that say that the Web hosts cannot be accessed etc. This is a command that I tried for simply printing a text file to the monitor. (A real Web site address was used, not the one listed here.) use LWP::Simple; LWP::Simple::getprint("http://www.webhost.com/file.txt");
From: Jens Thoms Toerring on 26 Jun 2010 08:47 E.D.G. <edgrsprj(a)ix.netcom.com> wrote: > I am running a recent version of the ActiveState Perl program with Windows > XP and Vista operating systems. The LWP module has been installed. > Could someone list the correct Perl code to use for having a Perl program > download and store or print a file from a Web site? > I read all of the online documentation I could locate and tried various > commands. However, error messages keep appearing that say that the Web > hosts cannot be accessed etc. > This is a command that I tried for simply printing a text file to the > monitor. (A real Web site address was used, not the one listed here.) > use LWP::Simple; > LWP::Simple::getprint("http://www.webhost.com/file.txt"); And that should work - it does for me when putting it into a Perl script or using e.g. perl -MLWP::Simple -e 'getprint "http://www.sn.no"' from the command line. Getting error messages about not being able to access the web server could be the result of a mis- configured system, that you entered an incorrect URL or that you either try to download a page that the web server is not allowed to serve. To find out what's going on you would have to post the error messages with the exact code you're using, without that everything is just pure guesswork. And also keep in mind that the module doesn't do authentification, a web page that you can view in your browser might only be available since you're logged in into that site already. Regards, Jens -- \ Jens Thoms Toerring ___ jt(a)toerring.de \__________________________ http://toerring.de
From: Tad McClellan on 26 Jun 2010 10:04 E.D.G. <edgrsprj(a)ix.netcom.com> wrote: > Could someone list the correct Perl code to use for having a Perl program > download and store or print a file from a Web site? > > I read all of the online documentation I could locate How about not-online documentation? Such as the documentation for the module that you are using. > and tried various > commands. However, error messages keep appearing that say that the Web > hosts cannot be accessed etc. Please post verbatim, not paraphrased, error messages, along with the actual code that you ran to generate those error messages. Have you seen the Posting Guidelines that are posted here frequently? > This is a command that I tried for simply printing a text file to the > monitor. (A real Web site address was used, not the one listed here.) Why is the one listed here not a real website? > use LWP::Simple; perldoc LWP::Simple has this as its first example: perl -MLWP::Simple -e 'getprint "http://www.sn.no"' That works fine for me. Does that work for you? -- Tad McClellan email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/" The above message is a Usenet post. I don't recall having given anyone permission to use it on a Web site.
From: RedGrittyBrick on 26 Jun 2010 14:33 On 26/06/2010 15:04, Tad McClellan wrote: > E.D.G.<edgrsprj(a)ix.netcom.com> wrote: > > >> use LWP::Simple; > > perldoc LWP::Simple > > has this as its first example: > > perl -MLWP::Simple -e 'getprint "http://www.sn.no"' > > That works fine for me. > It probably wouldn't for E.D.G. because, as mentioned, he is using ActiveState which means he is probably using Windows and needs to use a different form of quoting: perl -MLWP::Simple -e "getprint 'http://www.sn.no'" If I recall correctly, the O.P. is liable to overlook this sort of detail unless reminded explicitly. Incorrect quoting may not be the cause of E.D.G's original problem of course. -- RGB
From: E.D.G. on 26 Jun 2010 22:25
"Tad McClellan" <tadmc(a)seesig.invalid> wrote in message news:slrni2c1v8.pie.tadmc(a)tadbox.sbcglobal.net... > perldoc LWP::Simple > has this as its first example: > perl -MLWP::Simple -e 'getprint "http://www.sn.no"' > That works fine for me. As I said, I checked multiple documentations including the ActiveState info and the Perl FAQ. That command was one that was tried with both my high speed service, dialup service, in a compiled program, from the Windows DOS command line, from the Windows Run command line and in a DOS batch file. It needs to have the following form to run without a format error message: perl -MLWP::Simple -e "getprint 'http://www.sn.no'" And the error that I keep getting for that (or any other Web site) is: 500 Can't connect to www.sn.no:80 (Bad hostname 'www.sn.no') (URL:http://www.sn.no) It might be an ActiveState + Widows problem. Quite often I have trouble getting commands to work properly as they appear in the documentation. It frequently takes a while to get the right format. Then they work fine from that point on. PPM connects properly to the Internet and downloads modules. So some type of command does work. |