popen, a funny thing

From: Date: Sat, 14 Oct 2000 10:02:11 +0000
Subject: popen, a funny thing
Groups: php.windows 
Request: Send a blank email to php-windows+get-3239@lists.php.net to get a copy of this message
I'm having a problem. when i run this script it has two diferent outputs, one in the browser and other in command line: The script is this: <body> <select name="files"> <? $path="c:\\inetpub\\wwwroot"; $cmd="dir /w " .$path; $fp=popen($cmd,"r"); if ($fp==false){ echo "ERRO"; } else{ $linha=fgets($fp,80); $linha=fgets($fp,80); $linha=fgets($fp,80); $linha=fgets($fp,80); $linha=fgets($fp,80); $j=1; $fn=array(); while (!feof($fp)){ $linha=fgets($fp,80); if ($linha[0]!=' '){ $fn=split(' +',$linha); for(;$i=next($fn);){ ?> <option value=<? echo $j++; ?>><? echo $i; ?></option> <? } } } } pclose($fp); ?> </select> </body> When i run in the browser the output is: <body> <select name="files"> </select> </body> but when i run in command line, the output is: C:\Inetpub\wwwroot\default>\php\php teste.php X-Powered-By: PHP/4.0.2 Content-type: text/html <body> <select name="files"> <option value=1>[..]</option> <option value=2>[ps2portugal]</option> <option value=3>[lusotour]</option> <option value=4>[default] </option> <option value=5>[Lome]</option> <option value=6>[Editor]</option> <option value=7>[NovoEditor]</option> <option value=8>teste.pl </option> <option value=9>lome.sql</option> <option value=10>README.txt</option> <option value=11>Editor.zip</option> <option value=12> </option> </select> </body> The goal of this script is to build a combo box for selecting all the files in a directory. I hope that anyone can tell me the problem, cause i can't figure it out :( ---------------------------------------------------------------------------- Hugo Alexandre Almeida Soares Dias MNI.pt E-mail: anikin@alfarrabio.di.uminho.pt Web-programmer HomePage: http://paginas.teleweb.pt/~hasd/ http://www.mni.pt/ http://www.saudenainternet.pt/ http://www.listamedica.pt ----------------------------------------------------------------------------

« previous php.windows (#3239) next »