|
Posted by Andy Hassall on 12/23/05 01:10
On Thu, 22 Dec 2005 23:50:22 +0100, "_andrea.l"
<andrea.lorizANTISPAM@libero.it> wrote:
>I'm writing a little script for reading information from a router by telnet.
>I have a problem
>
>How give a comand and get the answer more times?
>I means:
>
>[...]
> $usenet = fsockopen($cfgServer, $cfgPort, &$errno, &$errstr, $cfgTimeOut);
>[...]
> fwrite ($usenet, "show interface description\r\n\n");
>[...]
>while (!feof($usenet))
>{
>$r1=fgets($usenet, 1000)."<BR>\n";
>}
>
>
>The program don't exit from while...
>... because the telnet don't give feof.
Are you expecting the device to drop the connection after one command? Or do
you need to send some sort of "exit" command after the "show interface
description" command?
Otherwise you need to find some sort of unique text that indicates the end of
the output, and use that to stop your while loop.
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Navigation:
[Reply to this message]
|