Reputation: 608
I'm trying to run file_creator.exe
via PHP which accepts some arguments and produces an output file. so how can I get the name of output file in order to produce the download link?
Upvotes: 0
Views: 3931
Reputation: 331
Please consider the Symfony Process library. It's a lot easier and safer to use it rather than just PHP functions like shell_exec
or proc_open
. Symfony Process wraps around these functions and provides extra level of security.
Upvotes: 0
Reputation: 12244
You will want to use shell_exec() function in PHP (http://php.net/manual/en/function.shell-exec.php) to run your exe file. Pass in the parameters in the command line such as:
<?php
$outputOfExecutable = shell_exec("C:\\path\\to\\cmd.exe /c C:\\batchfile.cmd");
?>
Whatever your executable returns at the end of it's execution is returned to your PHP script. This means that your executable should return the path of the file it generated so you can actually read it with PHP or it could return the file content and you write it to disk, it's as you wish.
Upvotes: 2