?
Solved

PHP Path for System() Command running in Apache

Posted on 2003-02-28
8
Medium Priority
?
180 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

762 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