ID: 24123
Updated by: [EMAIL PROTECTED]
Reported By: zambrow at hotmail dot com
-Status: Open
+Status: Bogus
Bug Type: Program Execution
Operating System: Windows 2000
PHP Version: 4.3.2
New Comment:
I presume you're using the stock "telnet" application delivered with
Win2000. This program does not permit communicating via redirected
pipes. This is most directly illustrated by the following command:
C:\> telnet 111.111.111.111 > telnet.log
One would expect telnet to behave nicely and send the welcoming
"login:" prompt to the telnet.log. However, it simply bails because
Windows Telnet doesn't like redirected pipes.
Thank Billy for that.
Unfortunately this isn't a bug in PHP and hence isn't something we can
do anything to correct.
Previous Comments:
------------------------------------------------------------------------
[2003-06-11 13:56:57] zambrow at hotmail dot com
the fwrite($pipes[1], "exit\r");
was just my mistake i made during debugging but it doesnt change
anything
I expect to see in pipes[1] the ouput of my telnet session. for example
writing ls to pipes[0] should result in pipes[1] having the output of
ls command in the running directory.
Adding your debugging function does not change anything. The script
will still just sit there for a long while and in the end it'll load
empty page.
Note i'm doing this on Windows 2000 machine. and my target os is AIX.
if i run the script on AIX to AIX platform this seems to work
------------------------------------------------------------------------
[2003-06-11 08:55:42] [EMAIL PROTECTED]
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).
------------------------------------------------------------------------
[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