mido45 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks

I want to some help with the following code:

my @array4=system'curl','-G','-x','127.0.0.1:8080','http:/ +/www.google.com' or die "system 'curl' failed: $?";

Output

curl: (7) couldn't connect to host

1792 #the process ID

I want to get the o/p of curl to directed to @array4 in order to make some checks

I tried this code to get the o/p to file

my @array4=system'curl','-G','-o',"result.txt",'-x','127.0.0.1:8080',' +http:/ +/www.google.com' or die "system 'curl' failed: $?";

So I could take the output from result.txt and check it but it did't work

If there are any ideas about how to solve it please reply

Thank you in advance

Replies are listed 'Best First'.
Re: Getting curl o/p
by toolic (Bishop) on Feb 17, 2010 at 18:54 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.

Re: Getting curl o/p
by zentara (Cardinal) on Feb 18, 2010 at 13:28 UTC
    You might want to try the Perl interface to libcurl, see WWW-Curl. You will then be able to get and manipulate all output and options. Another option is to run curl thru IPC::Open3 instead of system, qx or backticks.

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku