RE: [PHP] Exec() in Windows NT

From: Date: Tue, 29 Aug 2000 17:03:18 +0000
Subject: RE: [PHP] Exec() in Windows NT
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-14180@lists.php.net to get a copy of this message
From: James Moore > > 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); > } I am having problems getting this to work without going into an infinite loop, but I will keep looking into this and will post my results. > or exec("progname.exe >file"); > then readin file and process it. This actually did not work (this was one of the first things that I tried) because the executable does not generate any output when called from PHP. This is what got me thinking about the IIS configuration: why is all output being squelched? Now, if progname.exe made its own system call system( "other.exe > file" ); ), that would work just fine, and I could read that text file. The no-output rule seems to only apply for the first call from a CGI application. This could be because the C system call evokes an actual Windows command where the PHP exec does not. Do you have a working example of using an exec under Windows? Matthew Aznoe Fuzz Technologies maznoe@fuzztech.com <mailto:  maznoe@fuzztech.com

« previous php.general (#14180) next »