0

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.

Cubi73
  • 1,891
  • 3
  • 31
  • 52
  • Have a look at [`shell_exec`](http://php.net/shell_exec). It returns the program output as a string. –  Oct 21 '13 at 15:26
  • Use an exe .Net app from PHP, via shell_exec...the problem is how do you get the otuput from the app...what kind of output that .net app produces? – Hackerman Oct 21 '13 at 15:44

1 Answers1

0

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. :)

BastetFurry
  • 299
  • 3
  • 18