| | |
exec() command and PATH issues
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2008
Posts: 38
Reputation:
Solved Threads: 1
Hi all,
I'm using exec() to launch external commands from a web application under OS X Leopard. To put my problem in context, when I launch this:
exec ("export", $output);
I get this:
export OLDPWD
export PATH="/usr/bin:/bin:/usr/sbin:/sbin"
export PWD="/Library/WebServer/Documents"
export SHLVL="1"
My problem is with PATH, I need to include other directories in there. I've been searching for some time now but can't put my finger on it. Any ideas?
Thanks!
I'm using exec() to launch external commands from a web application under OS X Leopard. To put my problem in context, when I launch this:
exec ("export", $output);
I get this:
export OLDPWD
export PATH="/usr/bin:/bin:/usr/sbin:/sbin"
export PWD="/Library/WebServer/Documents"
export SHLVL="1"
My problem is with PATH, I need to include other directories in there. I've been searching for some time now but can't put my finger on it. Any ideas?
Thanks!
Last edited by LeBurt; Mar 28th, 2008 at 11:38 am.
•
•
Join Date: Mar 2008
Posts: 38
Reputation:
Solved Threads: 1
There's nothing like posting a question to find the answer yourself shortly after...
I solved my problem by adding this at the beginning of my script:
putenv("PATH=" .$_ENV["PATH"]. "my/other/directories");
Works well, however I suspect there is another, more elegant, way to set the PATH in a .ini or .conf file somewhere. I looked at php.ini but didn't really see anything relevant in there.
Where might it be?
Thanks.
I solved my problem by adding this at the beginning of my script:
putenv("PATH=" .$_ENV["PATH"]. "my/other/directories");
Works well, however I suspect there is another, more elegant, way to set the PATH in a .ini or .conf file somewhere. I looked at php.ini but didn't really see anything relevant in there.
Where might it be?
Thanks.
•
•
Join Date: Mar 2009
Posts: 1
Reputation:
Solved Threads: 0
You may try something like:
in your httpd.conf
I was running wamp under windows, and my solution was to set the windows path, and then rebooting. But your solution pointed me in the right direction, so thank you!
PHP Syntax (Toggle Plain Text)
SetEnv PATH my/other/directories
I was running wamp under windows, and my solution was to set the windows path, and then rebooting. But your solution pointed me in the right direction, so thank you!
![]() |
Similar Threads
- popups persist despite all efforts, load.html in temp folder... (Viruses, Spyware and other Nasties)
Other Threads in the PHP Forum
- Previous Thread: Warning: Wrong parameter count for mysql_query()
- Next Thread: Incrementing input per paragraph
| Thread Tools | Search this Thread |
advanced apache api array beginner binary broken cakephp check checkbox class cms code cookies cron curl database date datepart display dropdownlist dynamic echo email eregi error execution file files folder form forms function functions google href htaccess html if...loop image include includingmysecondfileinthechain insert ip javascript joomla jquery key library limit link login mail menu mlm multiple mysql oop password paypal pdf pdfdownload php phpvotingscript problem query radio random recursion regex remote screen script search server sessions smarty sms soap sorting source space sql startup stored syntax system table traffic tutorial update upload url validator variable video web xml youtube zend





