Solved

exec() works locally but not remotely

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Re-imbursement Claim System 3 25
How to validate 2 forms at once 8 27
how can I dected if URL has variable? 7 23
Button Click 11 26
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to count occurrences of each item in an array.
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…

747 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

14 Experts available now in Live!

Get 1:1 Help Now