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

I am trying to post some basic xml via https post and I am having minor trouble. First I tried using LWP::UserAgent and it kept giving me errors when I tried to install the module so I gave up on that method. I then found a little tutorial on how to do with with curl:

#!/usr/bin/perl use URI::Escape; use IPC::Open2; my $post_url = "https://www.domain.com/cgi-bin/AcceptXML"; my $curl = "/usr/local/bin/curl"; my $curl_opt = "-H 'Content-Type: text/xml'"; my $basic_auth = ""; $post_url =~ s|://|://$basic_auth\@| if $basic_auth; open2(*README, *WRITEME, "$curl $curl_opt -d \@- $post_url 2>/dev/null +"); my $xml_out = qq[<?xml version="1.0" encoding="UTF-8"?> <SomeXml> <SomeData>1234</SomeData> <SomeOtherData>x=25%</SomeOtherData> <MoreData id="445A">Pink Elephants</MoreData> </SomeXml> ]; print WRITEME &uri_escape($xml_out); close WRITEME;
I run it with all my iformation and I dont get any kind of response back so I dont know if it went through or not. How can I get the response and just print it out to the console? It looks like it might be writting the reponse somewhere, just not sure where. Thanks.

Replies are listed 'Best First'.
Re: HTTPS post with curl (RESOLVED)
by jasonk (Parson) on Feb 01, 2006 at 03:35 UTC

    Your response isn't going anywhere, you use IPC::Open2 to open a reader and a writer filehandle to the curl process, but then you never read from the reader, so when your process exits, the system throws all the output away. Try adding something like 'print <README>' to the end of the script.


    We're not surrounded, we're in a target-rich environment!