[thelist] Running exe files from php

Jackson Yee jyee at vt.edu
Tue Feb 4 17:45:01 CST 2003


"Josh" <josh at eaccessit.com> wrote in message
news:000101c2cc99$1ca71610$6fa8f396 at xyz...
> I need to run an exe file from a PHP page.  How would I do this?  I have
> tried passthru("C:\path\program.exe", $results); but results always
> comes back as 1.  What I am I doing wrong?
>
> The program.exe is a simple exe program that just puts "testprogram" to
> the console. Shouldn't $results come back as "testprogram"??!  PHP is
> not in safemode.

Try reading the documentation for passthru() a bit more carefully, Josh.
Specifically the part

"the return_var argument is present, the return status of the Unix command
will be placed here."

$results will be thus be the exit code of the program, not its output, which
goes straight to the browser.  I wonder why it's 1 though; most programs
return 0 for a successful run.

Try echo system() rather than using passthru() and see what happens.  I'm
not sure whether the problem lies within your program or with PHP.

--
Regards,
Jackson Yee
jyee at vt.edu





More information about the thelist mailing list