|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-06-11 08:55 UTC] wez@php.net
[2003-06-11 13:56 UTC] zambrow at hotmail dot com
[2003-08-09 20:10 UTC] pollita@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 11:00:02 2025 UTC |
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...