in reply to Getting curl o/p

Try qx instead of system

Replies are listed 'Best First'.
Re^2: Getting curl o/p
by mido45 (Novice) on Feb 17, 2010 at 19:28 UTC

    Thank you toolic for the quick response

    I tried this code

    my $result=`curl '-G''-x' 127.0.0.1:8080 http:/+/www.google.com 1>prog +ram.stdout 2>program.stderr`;

    I see in the program.stderr the following:

    curl: option -G-x: is unknown

    curl: try 'curl --help' for more information

    1-How can I make it work right?

    2-I want to add variables one for ip and another for port instead of 127.0.0.1:8080, Will it work?

      There are two simple steps to "making it work right":

      1. Make it work right on the shell command line without Perl
      2. Make it work within Perl

      As soon as your command works under condition 1, it will also work under condition 2. Currently, you will find that your approach does not work under condition 1. Fix that.

        Thank You Corion

        I followed your steps and it worked

        my $result=`curl -G -x127.0.0.1:8080 http://www.google.com 1>program.s +tdout 2>program.stderr`; print"$result\n";

        I will try now to replace 127.0.0.1:8080 with variables , I hope it will work too