?
Solved

PHP Path for System() Command running in Apache

Posted on 2003-02-28
8
Medium Priority
?
183 Views
Last Modified: 2006-11-17
I am trying to run a system() command but it is failing because it doesn't know where to find the command.  If I run system("echo $PATH") it responds back "/usr/sbin:/usr/bin".  When I run phpinfo() every PATH that seems pertinent responds back "/usr/sbin:/usr/bin".  I am running the script and PHP through Apache_1.3.27, how do I change the default PATH?

Answers that change the PATH for a single script will not help, I have multiple scripts pulled down from various locations on the web and would prefer not to have to visit each file for each application to make the change take affect.

--goodatunix
0
Comment
Question by:goodatunix
  • 4
  • 3
8 Comments
 
LVL 8

Expert Comment

by:us111
ID: 8042994
you should specify all the time the path to the command or to the file. for instance:
system("/usr/bin/image /home/goodatunix/file.jpg");
0
 
LVL 8

Expert Comment

by:us111
ID: 8043040
you should specify all the time the path to the command or to the file. for instance:
system("/usr/bin/image /home/goodatunix/file.jpg");
0
 
LVL 8

Expert Comment

by:us111
ID: 8043062
try
$_SERVER['PATH']= "all path";

or see the putenv function
http://www.php.net/manual/en/function.putenv.php
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:goodatunix
ID: 8043196
Simply changing the command to include the full path will not work.  I don't want to have to visit each script.  I would prefer to find a way to change the environment variable for PATH that is passed to PHP.
0
 

Author Comment

by:goodatunix
ID: 8043269
Simply changing the command to include the full path will not work.  I don't want to have to visit each script.  I would prefer to find a way to change the environment variable for PATH that is passed to PHP.
0
 

Author Comment

by:goodatunix
ID: 8044760
I found the answer after much searching... It seems that when the service is started it takes the PATH from the environment.  I modified apachectl so that it included a "PATH=/usr/local/bin:$PATH; export PATH" statement.  Then ran phpinfo() and found that the PATH had been updated.

--goodatunix
0
 
LVL 8

Expert Comment

by:us111
ID: 8045000
don't forget to close the question
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8045496
PAQ'd points refunded

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question