Solved

exec() works locally but not remotely

Posted on 2003-11-23
2
726 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MySQL Persistent Connections 10 50
MySQL-Design Help 12 63
Echo values after a query in php 5 48
php time 12 21
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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…
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…

738 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