John
John

Reputation: 197

PHP call exe and get return value

In my PHP project, I have an executable (Windows, .exe) which needs to be ran ocassionally by PHP itself. I'm aware of exec and shell_exec but am not sure whether this is actually what I'm looking for.

The executed application (console application, .NET) returns at least one line in the console, this shall now be grasped by PHP. And I even wonder whether it's possible to get more than one line from the console, so for example if the console's logging what it does?

Upvotes: 1

Views: 2306

Answers (2)

vikkio
vikkio

Reputation: 91

I would not use exec, I would use system

http://php.net/manual/en/function.system.php

Upvotes: 0

nithinTa
nithinTa

Reputation: 1642

Quoting from the manual http://php.net/manual/en/function.exec.php

string exec ( string $command [, array &$output [, int &$return_var ]] )

$output If the output argument is present, then the specified array will be filled with every line of output from the command.

$return_var If the return_var argument is present along with the output argument, then the return status of the executed command will be written to this variable.

Return Values The last line from the result of the command. If you need to execute a command and have all the data from the command passed directly back without any interference, use the passthru() function.

Upvotes: 2

Related Questions