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");
In reply to system() frustration by Red_King
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |