RE: [PHP] Exec() in Windows NT
| From: | James Moore | Date: | Tue, 29 Aug 2000 16:31:40 +0000 |
| Subject: | RE: [PHP] Exec() in Windows NT | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-14169@lists.php.net to get a copy of this message | ||
> I posted a question earlier regarding this topic, and after investigating
> still further, the evidence seems to indicate that the output is not
> returned by exec() due to the configuration of the Internet Information
> Server. When I run my PHP scripts from the DOS prompt, it works as
> expected, but when I access the same scripts (through the same PHP CGI
> program), the files no longer send output.
>
> I am trying to retrieve some configuration data from another application.
> In order to handle the changes in configuration file's format, they have
> provided an executable that returns requested values by outputing them to
> the screen. In Linux, this works great since I can use the exec
> command to
> retrieve the output and populate my variables. In Windows, I have
> discovered, it does not, because no output is generated by
> programs executed
> by the exec() function.
>
> However, I have found an interesting work-around (which I
> despise) in that I
> can call another executable via the exec command that then calls this
> configuration application with a redirect to a file. This file
> can then be
> read by PHP to get the data... extremely clunky.
>
> Is there a way to configure IIS to allow executables to generate
> output when
> called from PHP? Or is this a problem with PHP-win32?
>
> Or, if all else fails, does anyone have any other more clever ideas for
> getting around this problem?
>
OK Various options.. Dont know if this will work but try the following..
after the exec
$fp = fopen("php://stdin",r);
while(!feof($fp)) {
echo fgets($fp);
}
or exec("progname.exe >file");
then readin file and process it.
James