PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Jun 16, 2019 3:03 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue Nov 09, 2010 8:55 pm 
Offline
Forum Newbie

Joined: Sun May 23, 2004 1:12 pm
Posts: 13
Location: Los Angeles, CA
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.


Top
 Profile  
 
PostPosted: Tue Nov 09, 2010 9:05 pm 
Offline
Forum Contributor

Joined: Sun Sep 09, 2007 6:27 pm
Posts: 282
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.


Top
 Profile  
 
PostPosted: Tue Nov 09, 2010 11:21 pm 
Offline
Forum Newbie

Joined: Sun May 23, 2004 1:12 pm
Posts: 13
Location: Los Angeles, CA
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?


Top
 Profile  
 
PostPosted: Wed Nov 10, 2010 2:43 am 
Offline
DevNet Master
User avatar

Joined: Wed Jun 27, 2007 9:44 am
Posts: 4313
Location: Sofia, Bulgaria
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?

Yes.

Try debugging it:
Syntax: [ Download ] [ Hide ]
echo exec("gnuplot '/Applications/IPG/htdocs/ftp/company_name/Charts/gnuPlotCommandFile.gp' 2>&1");


Also, always use absolute paths, including the command itself (i.e. gnuplot in this case)

_________________
There are 10 types of people in this world, those who understand binary and those who don't


Top
 Profile  
 
PostPosted: Wed Nov 10, 2010 1:38 pm 
Offline
Forum Newbie

Joined: Sun May 23, 2004 1:12 pm
Posts: 13
Location: Los Angeles, CA
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group