Red_King has asked for the wisdom of the Perl Monks concerning the following question:
My problem is that the last line creates an empty file every time. I can run the same line from the shell and it retrieves the picture. I wrote another script:#!/usr/bin/perl -w # collects the daily pic from the nasa web site $baseurl = "http://antwrp.gsfc.nasa.gov/apod/"; $fullurl = "http://antwrp.gsfc.nasa.gov/apod/astropix.html"; $newurl = ""; $status = ""; # get the html source for the page @source = `lynx -source $fullurl`; # scan the source and find the url for the picture foreach (@source) { if (m/IMG/i) { s/<IMG SRC=//i; # strip off the front of the tag s/><\/a>//i; # strip off the back of the tag s/\"//g; # strip off the double quotes $newurl = $baseurl.$_; print "retrieving $newurl"; } } $status = system("lynx -source $newurl > wallpaper.jpg");
----------------------------------------------------------- just to see whats wrong and it runs fine. What am i doing wrong, and how can i fix it? Thanks in advance.#!/usr/bin/perl $url = "http://antwrp.gsfc.nasa.gov/apod/image/0102/iss_sts98a.jpg"; print "retrieving $url"; $status = system ("lynx -source $url > wallpaper.jpg");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: system() frustration
by arturo (Vicar) on Mar 01, 2001 at 00:49 UTC | |
|
Re: system() frustration
by BlueLines (Hermit) on Mar 01, 2001 at 00:46 UTC | |
|
Re: system() frustration
by Red_King (Initiate) on Mar 01, 2001 at 01:10 UTC | |
|
Re: system() frustration
by Masem (Monsignor) on Mar 01, 2001 at 01:18 UTC | |
|
Re: system() frustration
by setantae (Scribe) on Mar 01, 2001 at 02:58 UTC |