Page 1 of 1

Problems executing a .exe file using external execution cmds

Posted: Tue Feb 15, 2005 8:27 am
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

Posted: Tue Feb 15, 2005 8:43 am
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..

Posted: Tue Feb 15, 2005 8:45 am
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

Posted: Tue Feb 15, 2005 8:51 am
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?

Posted: Tue Feb 15, 2005 9:37 am
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

Posted: Tue Feb 15, 2005 9:38 am
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.

Posted: Tue Feb 15, 2005 10:25 am
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....