VikR Posted November 10, 2010 Share Posted November 10, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/218251-exec-and-system-not-working/ Share on other sites More sharing options...
trq Posted November 10, 2010 Share Posted November 10, 2010 Command executed by PHP have the same permissions that your web server has. make sure your Apache user has sufficient permissions to execute the commands. Quote Link to comment https://forums.phpfreaks.com/topic/218251-exec-and-system-not-working/#findComment-1132496 Share on other sites More sharing options...
VikR Posted November 10, 2010 Author Share Posted November 10, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/218251-exec-and-system-not-working/#findComment-1132520 Share on other sites More sharing options...
trq Posted November 10, 2010 Share Posted November 10, 2010 Will Apache have different permissions for accessing files on the disk, than I have when I am running a command via the Terminal? Yes. You can find the user & group Apache runs under within Apache's main configuration file httpd.conf. Quote Link to comment https://forums.phpfreaks.com/topic/218251-exec-and-system-not-working/#findComment-1132527 Share on other sites More sharing options...
VikR Posted November 10, 2010 Author Share Posted November 10, 2010 Checking httpd.conf, I see: <IfModule !mpm_winnt.c> <IfModule !mpm_netware.c> # # If you wish httpd to run as a different user or group, you must run # httpd as root initially and it will switch. # # User/Group: The name (or #number) of the user/group to run httpd as. # . On SCO (ODT 3) use "User nouser" and "Group nogroup". # . On HPUX you may not be able to use shared memory as nobody, and the # suggested workaround is to create a user www and use that user. # NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET) # when the value of (unsigned)Group is above 60000; # don't use Group #-1 on these systems! # User myAdminUsername Group #-1 </IfModule> </IfModule> Next to "User" it shows the same admin name I use when logging in. I would think this would mean it would have full access to all files and folders. What could I be missing? Quote Link to comment https://forums.phpfreaks.com/topic/218251-exec-and-system-not-working/#findComment-1132534 Share on other sites More sharing options...
VikR Posted November 10, 2010 Author Share Posted November 10, 2010 It's working now. I needed to provide full path info to gnuplot. Code currently being used: $shellCommmand = "/usr/local/bin/gnuplot '" . $pathToCommandFile . "'"; $output = system($shellCommmand . " 2>&1"); Quote Link to comment https://forums.phpfreaks.com/topic/218251-exec-and-system-not-working/#findComment-1132715 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.