phpftpexeexecutepassthru

PHP and EXE files


When I searched for a way to execute a PHP script within another PHP script, I found the function passthru() at http://www.php.net/manual/de/function.passthru.php. I scrolled down and saw something with the registry, command line and EXE files. Is it possible to run a EXE file from a PHP script (with passthru(), exec() or something else) on a server.

If it is possible, is there a way to get the result or output of the EXE file?

And if all works, is there a way to use .NET applications?

Thank you in advance :)

I'm sorry, if my English isn't very good.


Solution

  • According to the manual passthru() does whats on the label, it passes trough stdout. If there is a browser on the other side it gets directly send to that.

    If you want the results you could try backticks, this works because PHP is loosely based on Perl. :)

    So, for example:

    $foo = `mybinaryprogramm someparameters $somemoreparametersrightfromavariable`;
    #now go and do something usefull with $foo
    

    I should mention that you should sanitize $somemoreparametersrightfromavariable somehow, but i hope that you see that as good practice. :)