cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Capturing curl response output in variable from command line script

From: haroon ahmad <haroon_at_fastcreators.com>
Date: Tue, 22 May 2007 18:21:32 +0500

Hi

I think it should work like this

$response = shell_exec("php script.php");

because the shell_exec will store whatever output it gets from the command
line in $response variable.

Regards,
Haroon Ahmad
Sr. Web Developer
www.fastcreators.com

On 5/22/07, Ketema J. Harris <ketema_at_ketema.net> wrote:
>
> I have a simple script that behaves differently if I run it from apache
> versus if i run it from the command line.
>
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL, 'http://www.some_script.php');
> curl_setopt($ch, CURLOPT_POST, 1);
> curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
> $response = curl_exec($ch);
>
>
> if (curl_errno($ch)) {
> print curl_error($ch);
> } else {
> curl_close($ch);
> }
>
>
> echo "This is the response\n $response\n";
>
>
> in apache the variable $response contains the html response from the web
> page. on the command line this variable only contains a 1 and the output is
> displayed on stdout. How can I cause the output to be stored in the
> variable instead of being printed to stdout?
>
>
> Thanks
>
> Ketema J. Harris
> www.ketema.net
> ketema_at_ketema.net
> ketemaj on iChat
>
>
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
>
>

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-05-22