I am having a problem running this command inside of php's exec command:
UPDATED WORKING CODE:
$results = exec('curl --dump-header - -H "Content-Type: application/json" -X PUT --data @data.json https://website.url --insecure', $output);
if ($results) {
echo "yay!";
var_dump($output);
echo $results;
} else {
var_dump($output);
echo "screw you";
}
originally the script together works in linux but inside php exec the inside single quotes conflicted with php's exec quotes. previous script:
curl --dump-header - -H "Content-Type: application/json" -X PUT --data '{"data": "foo", "data2": "bar"}' https://website.url
I'm wondering what might solve this quotes problem, I thought the escapeshellarg()
might do it but to no avail.
Update:
Error from Error page
PHP Warning: escapeshellarg() expects exactly 1 parameter, 0 given