in reply to capture system output

Not that it's an answer to your difficulties with system, but rather than shelling out to wget consider LWP::Simple or LWP::UserAgent instead.

Update: And if by "output" you mean the wget status information, that's getting written to STDERR not STDOUT so you'd need to redirect that instead.

Replies are listed 'Best First'.
Re^2: capture system output
by Galen (Beadle) on Jan 18, 2006 at 22:15 UTC
    I'm not as interested in the actual file retrieved. What I am looking to measure is the response time, so I want to see the output from wget showing when download began and completed. This is why I would prefer to parse the output within perl rather than capturing things I don't need into a file and parsing on the backend.

      Again, just use LWP (and possibly Time::HiRes if you want finer than second granularity).

      use LWP::Simple qw( get ); use Time::HiRes qw( time ); my $url = "http://..."; my $start = time; getstore( $url, "/dev/null" ); my $end = time; print "Took ", $end - $start, " seconds\n";

      What's wrong with

      use LWP::Simple qw( get ); use Time::HiRes qw( time ); my $url = "http://www.perlmonks.org/"; my $start_time = time; get($url); my $end_time = time; print("The transfer took ", $end_time-$start_time, " seconds.\n");

      You could easily put that into a loop and take the average (but beware of caching proxies).

      Update: oops, I was a bit slow at posting this!

      My weblint program, available on CPAN, has a download timer:

      $ weblint++ -t http://www.perlmonks.com 2.315 seconds

      It's probably easier to do it yourself as some of the other posts showed you, though.

      --
      brian d foy <brian@stonehenge.com>
      Subscribe to The Perl Review