#24123 [Opn->Fbk]: proc_open Apache 1.3.27 with php 4.3.2

From: Date: Wed, 11 Jun 2003 13:55:43 +0000
Subject: #24123 [Opn->Fbk]: proc_open Apache 1.3.27 with php 4.3.2
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-41676@lists.php.net to get a copy of this message
ID: 24123 Updated by: wez@php.net Reported By: zambrow at hotmail dot com -Status: Open +Status: Feedback Bug Type: Scripting Engine problem Operating System: Windows 2000 PHP Version: 4.3.2 New Comment: Your script is broken (why are you writing "exit" to $pipes[1]?). Can you please indicate what you expect to see, and what you actually end up with? Add this line after the proc_open call: debug_zval_dump($pipes); Also note that for telnet on most unix platforms, you need to run it via the "expect" utility to correctly emulate an interactive tty. (I know this is listed as a win32 issue, but its worth mentioning this in any case). Previous Comments: ------------------------------------------------------------------------ [2003-06-11 08:43:09] zambrow at hotmail dot com Apache 1.3.27 with php 4.3.2. I'm tryin to implement a way to do a 2-way communication through telnet for my script here's what I've found! (111.111.111.111 example ip is a unix box and it is accepting telnet connections" Consider this. $failed = false; // authentication failure flag $cmd="telnet 111.111.111.111"; $descriptorspec = array( 0 => array("pipe", "r"), // stdin is a pipe that the child will read from 1 => array("pipe", "w"), // stdout is a pipe that the child will write to 2 => array("pipe", "w") // stderr is a pipe that the child will write to ); $userID="user"; $password="password"; $process = proc_open("$cmd", $descriptorspec, $pipes); echo $process; if (is_resource($process)) { fwrite($pipes[0], "$userID\r"); fwrite($pipes[0], "$password\r"); fwrite($pipes[1], "exit\r"); while(!feof($pipes[1])) { $line = fgets($pipes[1], 1024); $loginFailed = strpos($line, "invalid login name or password"); if ($loginFailed != false) { $failed = true; // echo "FAILED LOGGING"; } // DEBUG OUTPUT echo $line; echo "---<br>"; } fclose($pipes[1]); $return_value = proc_close($process); echo "<br><b>command returned<b> $return_value\n"; } The following will result in empty pipes[1]. I'm unable to get anything out of that pipe as well the fgets just seems to hang. when i try the same code on AIX platform it works. So i'm thinking its a bug... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=24123&edit=1

« previous php.bugs (#41676) next »