943,844 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 6154
  • PHP RSS
Mar 28th, 2008
0

exec() command and PATH issues

Expand Post »
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!
Last edited by LeBurt; Mar 28th, 2008 at 11:38 am.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
LeBurt is offline Offline
38 posts
since Mar 2008
Mar 31st, 2008
0

Re: exec() command and PATH issues

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.
Reputation Points: 10
Solved Threads: 1
Light Poster
LeBurt is offline Offline
38 posts
since Mar 2008
Mar 11th, 2009
0

Re: exec() command and PATH issues

You may try something like:
PHP Syntax (Toggle Plain Text)
  1. SetEnv PATH my/other/directories
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!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
magicgunnar is offline Offline
1 posts
since Mar 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Warning: Wrong parameter count for mysql_query()
Next Thread in PHP Forum Timeline: Incrementing input per paragraph





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC