tags:

views:

55

answers:

1

I'm using proc_open to launch a telnet session connecting to a server program. Connection is ok but when I get the reply, I can't store the whole string on a file as it is cut after some chars.

Here is my snippet:

$descriptorSpec = array( 0 => array( "pipe", "r" ),  
                         1.=> array( "file", $logPath, "w" ) );  
$process = proc_open( "telnet localhost 2323", $descriptorSpec, $pipes );  
fwrite( $pipes[0], "helo" . PHP_EOL );
fwrite( $pipes[0], "quit" . PHP_EOL );

I've also tried using netcat and exec:

exec( "echo \"helo quit\" | netcat localhost 2323 >> $logPath" );

but I had the same result.

If I run the telnet/netcat command from the console, I get the whole string on stdout but if I try to redirect it to another file I get the same prob as above.

A: 

Still no way even trying with the following:

$outArray = array(); exec( "echo \"helo quit\" | netcat localhost 2323", $outArray );

In the beginning it looked like it was working but after a few tests I realized this is not enough yet: part of the log is lost.