0

I have a web accessible PHP script that is using a shell command to drop PDFs to text. I installed Poppler, and am using pdftotext, via MacPorts. I am able to run the command successfully from the CL, and when supplying the full path within the PHP script to '/opt/local/bin/pdftotext'. So, I know that my $PATH is correct and the permissions are sufficient, yet I am still getting an exit status of 127: Command Not Found, when attempting to do simply 'pdftotext' in the exec().

I have tried the answers from How do I add paths to the Apache PATH variable? and http://lists.apple.com/archives/macos-x-server/2008/Sep/msg00433.html. I modified both the /etc/paths and /etc/profile, and added /etc/paths.d/macports all pointing to '/opt/local/bin'. setenv, apache_setenv, etc all had no effect also.

I am using a MAMP (1.9 I think) install for my local development, OSX 10.6, PHP 5.3.5, all a little behind I know :-) ... my $PATH is modified to point to the MAMP bin/php

Community
  • 1
  • 1
Wayne Weibel
  • 933
  • 1
  • 14
  • 22

1 Answers1

1

/etc/paths.d/macports will influence on PATH variable for macports, not for the Apache. You probably need to add /etc/parhs.d/apache (or else) to do what you need.
Edit: also check this and this threads for solutions. It is somewhat outdated but still can help.

Community
  • 1
  • 1
cody
  • 3,233
  • 1
  • 22
  • 25
  • so the name of the file in /etc/paths.d is for the process requesting the path, not the name of what the path is for? sadly, adding both 'apache' and 'php' had no effect. – Wayne Weibel Mar 26 '13 at 17:18
  • @WayneWeibel I've added links to the answer - check may be you'll find solution there. – cody Mar 27 '13 at 06:19
  • Thanks. The links did help. I was able to at least get the path correct using putenv. Still a little hacky for my taste, may switch to proc_open for executing the command. The shell is 'sh' that PHP is using, so next is making the correct .profile (hopefully). Thanks again. – Wayne Weibel Mar 27 '13 at 14:13