You are here: Re: telnet problem with PHP « PHP Programming Language « IT news, forums, messages
Re: telnet problem with PHP

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация