cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Curl, Perl and error codes

From: Adnane <adnane_at_gmail.com>
Date: Wed, 20 Aug 2008 10:29:27 -0400

Thanks for the reply.
The weird thing is that I tried other system commands with qx and they works
as expected. Here's a sample of the code:
#$file is an object representing an XML file
my $info = "";
my $info2 = "";
my $data = "";
## These next 2 lines are the ones causing me issues
$info = qx{/usr/bin/curl -b cookies -c cookies -d
"user=xxx&password=xxx&switch=Log+In" https://URL/FOLDER/SUBFOLDER/};
$info2 = qx{/usr/bin/curl -b cookies -c cookies -F File=\@$file
https://URL/FOLDER/SUBFOLDER/};
## Example of system command that works
$data = qx{date};
print "INFO: $info\n";
print "INFO2: $info2\n";
print "DATA: $data\n";
The output is:
curl: (6) Couldn't resolve host 'URL'
curl: (6) Couldn't resolve host 'URL'
INFO:
INFO2:
DATA: Wed Aug 20 10:13:49 EDT 2008

The problem again is that I want the first 2 lines of the output to be
assigned to $info and $info2 respectively, but for whatever reason, the curl
error message is printed on the terminal and nothing is assigned to the
variables. How can I modify the program to accomplish that goal?
Any help is appreciated.
Thanks

On Tue, Aug 19, 2008 at 12:13 PM, Jake Peavy <djstunks_at_gmail.com> wrote:

> On 8/19/08, Adnane <adnane_at_gmail.com> wrote:
>>
>> Hey guys,
>> This is my first post on this list so please excuse my ignorance.
>> I'm writing a perl application to send an xml file to a remote server and
>> I'm using curl through system calls: qx (for reasons beyond my control, I
>> can't install the Curl::Easy module on this machine).
>> When the transfer fails, a message such as: 'curl: (7) socket error: 111'
>> is printed on the terminal.
>> My question is: is there any way to get that error code (7 in this case)
>> inside the perl code and assign it to a variable that I can then act upon
>> (maybe send an email)?
>> I searched all over the net and couldn't find an answer.
>> <http://curl.haxx.se/mail/etiquette.html>
>
>
> This is not a cURL question, this is a Perl question.
>
> See perldoc perlvar, in particular $CHILD_ERROR
>
> --
> -jp
>
> Is there anything more beautiful than a beautiful, beautiful flamingo,
> flying across in front of a beautiful sunset? And he's carrying a beautiful
> rose in his beak, and also he's carrying a very beautiful painting with his
> feet. And also, you're drunk.
>
> deepthoughtsbyjackhandy.com
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
> FAQ: http://curl.haxx.se/docs/faq.html
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>
>

-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2008-08-20