Solved

exec() works locally but not remotely

Posted on 2003-11-23
2
716 Views
Last Modified: 2013-12-13
I have this:

index.php
-----------
<?
echo "Execute Test<br>";
$num = 1;
$array = array();
$str = exec("php.exe myFile.php",$array,$num);
echo "$str<br>";
foreach($array as $k=>$v)
  echo "$k $v<br>";
?>

This works locally on my computer (Apache 2.0.47) but doesn't work my host's server (Apache 1.3.28).  I know exec() is permitted on my host's server b/c I told them I needed to use this function and they put me on a server that allows it (also, the first server they had me on gave me an error saying exec() was disabled for security reasons when I tried to use it).  So I think the problem is in the path I giving.  I've tried these variations:

exec("/php.exe myFile.php",$array,$num)
exec("./php.exe myFile.php",$array,$num)
exec("/www/php.exe myFile.php",$array,$num)
exec("/home/{my username}/www/php.exe myFile.php",$array,$num)

php.exe is the Command Line Interface version of PHP which is in the same directory as myFile.php and index.php.  There's no output from the 'echo $str' line or the foreach loop, but I do see "Execute Test" at the top of the screen.  One difference between my local and remote exec() lines is that I give the full path (C:\...) to the php.exe locally but not remotely b/c I don't know the full remote path.  What's going wrong here?

bmh
0
Comment
Question by:bmh777
2 Comments
 

Accepted Solution

by:
bmh777 earned 0 total points
ID: 9815553
I got it to work.  I had to put a server directive in myFile.php that tells the server to use the PHP executable to parse the file.  I also had to chmod myFile.php to 755.

bmh
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

863 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

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now