When executed from the terminal, the following command works perfectly:
gnuplot '/Applications/IPG/htdocs/ftp/company_name/Charts/gnuPlotCommandFile.gp'
However, when I run it from inside PHP with:
exec("gnuplot '/Applications/IPG/htdocs/ftp/company_name/Charts/gnuPlotCommandFile.gp'");
...or:
system("gnuplot '/Applications/IPG/htdocs/ftp/company_name/Charts/gnuPlotCommandFile.gp'");
...nothing seems to happen. How can I correct this?
Note - exec is enabled on my system, according to the following function:
function exec_enabled() {
$disabled = explode(', ', ini_get('disable_functions'));
return !in_array('exec', $disabled);
}
Thanks very much in advance to all for any info.
System() and Exec() Not Working?
Moderator: General Moderators
Re: System() and Exec() Not Working?
There are many possible reasons for the failure, probably all permissions related in one way or another. Start by reviewing the server logs for any error messages that help you identify the problem. Maybe your server php has an open_basedir restriction, more likely the web server user doesn't have permission to run the script.
Re: System() and Exec() Not Working?
I am running Apache via MAMP, a local amp stack running on my development system on my iMac. I am running MAMP and the Terminal in my own user account. Will Apache have different permissions for accessing files on the disk, than I have when I am running a command via the Terminal?
Re: System() and Exec() Not Working?
Yes.Vik wrote:Will Apache have different permissions for accessing files on the disk, than I have when I am running a command via the Terminal?
Try debugging it:
Code: Select all
echo exec("gnuplot '/Applications/IPG/htdocs/ftp/company_name/Charts/gnuPlotCommandFile.gp' 2>&1");There are 10 types of people in this world, those who understand binary and those who don't
Re: System() and Exec() Not Working?
That solved it! Using the exec command per your sample code revealed the error "sh: gnuplot: command not found". Providing full path to gnuplot, (on my system, "/usr/local/bin/gnuplot"), then fixed that. It's working now. I really appreciate your help. Thanks very much!