All right...look at this piece of code, and please ignore the fact that i could use LWP to do the same thing...
#!/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");
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 $url = "http://antwrp.gsfc.nasa.gov/apod/image/0102/iss_sts98a.jpg"; print "retrieving $url"; $status = system ("lynx -source $url > 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.

In reply to system() frustration by Red_King

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.