Problems executing a .exe file using external execution cmds

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Problems executing a .exe file using external execution cmds

Post by mjseaden »

Hi,

I've tried using exec(), system(), passthru() and shell_exec() on a binary .exe file with PHP safemode off, however none of the commands are producing and output and therefore don't seem to be executing the file. Here's the code (ignore the complexities of the parameters). I know this command works because it outputs when run directly from a UNIX shell window, it's just when I try and run it under PHP, it doesn't output anything and doesn''t run.

Code: Select all

$output = shell_exec('/sample_gals_shortcut4.exe /gal/r2/cmb/Grasil_Out//eGalform_Cole2000/z/cat 0 1 0.0 -9931 AB dust/dust_MW_hz1.0.dat 0 1 0.25 file /usr/local/www/galform/Junk/table_junk range mstars_total 0.0 1.e+10 props weight mstars_total magK_tot_ext >&! /usr/local/www/galform/Junk/table_junk');
Any ideas? Do I have to set a PHP_exec directory or something?

Cheers

Mark
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you sure that's the correct file page to the exe? that'd be in the file system's root. It appears that you have redirection in there as well, which may shunt the process to a background thread..
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Post by mjseaden »

Can you explain what you mean by correct file page? I'm a bit of a novice at running external programs through PHP. How do I check the file page on the system's root?

Many thanks

Mark
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

sorry, file path. Where is this exe located in the system directories? Where is the php file located in the system directories? Is the exe in a %PATH% location?
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Post by mjseaden »

Hi feyd

The file path i've changed to be stated in full $_SERVER['DOCUMENT_ROOT'].'/galform/sample_gals_shortcut4.exe ...

However, it's still not working. Safemode is off, and the $output is still returned empty.

I suspected this might happen for some reason, as I have had difficulty before running a binary EXE using PHP or other shelll execution commands.

Any ideas? Any help gratefully received.

Many thanks

Mark Seaden
mjseaden
Forum Contributor
Posts: 458
Joined: Wed Mar 17, 2004 5:49 am

Post by mjseaden »

Just as an addition, I've checked the error logs and it doesn't seem to be producing any errors for this script.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

btw, you are redirecting all output to >&! /usr/local/www/galform/Junk/table_junk


probably, that program outputs stderr also to your console... and that is why you get to see it... might want to try whatevercommand 2>&1 to make sure stderr also is redirected to stdout....
Post Reply