cURL / Mailing Lists / curl-library / Single Mail


RE: stderr - access violation

From: O'Loughlin, Anthony (MED US) <>
Date: Thu, 10 Apr 2008 07:16:20 -0400

I'm running on Windows. Do you think this is windows specific?

Thanks for the code. Tony

-----Original Message-----
[] On Behalf Of Guenter Knauf
Sent: Wednesday, April 09, 2008 6:39 PM
Subject: Re: stderr - access violation

> I've looked at the manual for using stderr and verbose. This snippet
> code creates the file (err.txt). However it is empty and the code
> violates.

> What I'm I missing? Thanks, Tony
I know this issue; seems that filehandles do not work here....; what OS
are you on?
Anyway, you need a write callback to make it working; try the below if
that works for you;
if so then all you need to do is to print the vars to your filehandles
instead of STDOUT.

# simple test script which uses the Perl5 libcurl bindings.

my $url = $ARGV[0] || '';

use WWW::Curl::Easy;

sub curl_write_callback {
  my ( $data, $pointer ) = @_;
  ${$pointer} .= $data;
  return length($data);

print "Perl Version: $]\n";
print "OS Version : $^O\n\n";

printf (" Version: %s\n", $WWW::Curl::Easy::VERSION);
printf ("libcurl Version: %s\n\n", WWW::Curl::easy::version());

print ("=" x 78 . "\n");

my $content;
my $headers;

my $curl = new WWW::Curl::Easy;
$curl->setopt( CURLOPT_FILE, \$content );
$curl->setopt( CURLOPT_HEADERFUNCTION, \&curl_write_callback );
$curl->setopt( CURLOPT_URL, $url );
$curl->setopt( CURLOPT_WRITEFUNCTION, \&curl_write_callback );
$curl->setopt( CURLOPT_WRITEHEADER, \$headers );
my $curl_info = $curl->getinfo(CURLINFO_HTTP_CODE);
my $curl_err = $curl->errbuf;

print "${headers}\n";
print ("=" x 78 . "\n");
print "${content}\n";
print ("=" x 78 . "\n");
print "${curl_info}\n";
print ("=" x 78 . "\n");
print "${curl_err}\n" if ($err);


This message and any included attachments are from Siemens Medical Solutions
and are intended only for the addressee(s).
The information contained herein may include trade secrets or privileged or
otherwise confidential information. Unauthorized review, forwarding, printing,
copying, distributing, or using such information is strictly prohibited and may
be unlawful. If you received this message in error, or have reason to believe
you are not authorized to receive it, please promptly delete this message and
notify the sender by e-mail with a copy to

Thank you
Received on 2008-04-10