1

(Doing this on OSX, apologize if off-topic)

When I run the line of code

shell_exec("/usr/local/bin/gnuplot gnuplot_script7"); 

inside a php script, a file named gnuplot_output7.png is generated, as expected. But when I run the similar line of code

shell_exec("gnuplot gnuplot_script7"); 

no image is generated! This despite that if I type

gnuplot gnuplot_script7

on the OSX command line, the image is successfully generated.

I typed - echo $PATH on the command line and got back

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/PostgreSQL/8.4/bin/:/usr/local/git/bin:/usr/X11/bin

and when I typed

which gnuplot

on the command line I got back

/usr/local/bin/gnuplot

1 Answer 1

2

Your user $PATH isn't the same as the user php is running.


Solution

1- Run php under your user (probably unsafe) and you can use:

shell_exec("gnuplot gnuplot_script7");

2 - Just use the full path:

 shell_exec("/usr/local/bin/gnuplot gnuplot_script7"); 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.