| | |
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
Views: 2537 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array autosuggest beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email emptydisplayvalue error explodefunction file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery keywords limit link login loop mail menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search searchbox select server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube





