?
Solved

exec() works locally but not remotely

Posted on 2003-11-23
2
Medium Priority
?
737 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
[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
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

Independent Software Vendors: 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!

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
The viewer will learn how to dynamically set the form action using jQuery.
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

752 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