in reply to Curl usage with Perl's system command
Hey there
You need to build up the parameter array manually, with each individual element, not all in one string. This way system will call curl directly, and not via the shell where the quoting gets complicated:
use strict; use warnings; use Capture::Tiny qw/ capture /; my ($to_id, $subject, $message) = qw(AA BB CC); my @args = ( '-v', '-s', '--user', 'api:key*****', '-F', "from=*****", '-F', "to=Name <$to_id>", '-F', "subject=$subject", '-F', "text=$message", 'https://api.****/**/*****/messages', ); my ($stdout,$stderr,$exit) = capture { system 'curl', @args; }; print $stdout,$stderr,$exit;
Added -v to the options so that you can see what is going on, although you wont want that once you get things sorted out. Another option is WWW::Curl on CPAN which has a Perl API overtop of Curl.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Curl usage with Perl's system command
by perlron (Pilgrim) on Oct 28, 2014 at 15:02 UTC | |
|
Re^2: Curl usage with Perl's system command
by perlron (Pilgrim) on Oct 28, 2014 at 16:32 UTC |