How to run curl at shell command line in PHP?
If I try to run this inside a script:
<?php exec("curl http://ww.google.com") ?> I get:
-bash-3.2$ php test.php sh: /curl: No such file or directory using shell_exec:
PHP Warning: shell_exec(): Cannot execute using backquotes in Safe Mode... How to run curl on a shell command line?
These errors occur on Linux, it works on my Mac.
The problem is that PHP safe mode is enabled, and it is better to use the full path to run cURL (thanks ghostJago and amosrivera). Running the script with the following command fixed the problem:
php -dsafe_mode=Off test.php I do not want to change php.ini , but it could also be a solution.
shell_exec reports a safe mode problem, but exec just tells you the wrong message, I hope I tried both exec and shell_exec .