473,385 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

telnet problem with PHP

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.
Hoh can I do?

Thank you in advance,
Andrea.

Dec 22 '05 #1
2 2938
On Thu, 22 Dec 2005 23:50:22 +0100, "_andrea.l"
<an******************@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 :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Dec 22 '05 #2
_andrea.l 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? <snip> The program don't exit from while...
... because the telnet don't give feof.
Hoh can I do?


When you telnet to the router 'by hand', how do you know the router has
finished the answer and is ready for more?

You have to make your script follow the same rules.
A long time ago I did a script that telnets to a POP3 server.

Have a look:
http://groups.google.com/group/comp....ffcd16c5b5f02f
and modify to your taste.

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Dec 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dan | last post by:
I'm writing a simplistic telnet client in VB6 and I've run into a small snag. The program has a textbox to write in the string to be sent using ..SendData and has another textbox that displays...
3
by: Yannick Turgeon | last post by:
Hello all, I'm currently trying to pass commands to a telnet session and get the texte generated (stdin + stdout) by the session. The problem I get is that the Telnet.read_until() function...
4
by: Donnal Walter | last post by:
On Windows XP I am able to connect to a remote telnet server from the command prompt using: telnet nnn.nnn.nnn.nnn 23 where nnn.nnn.nnn.nnn is the IP address of the host. But using telnetlib,...
2
by: john brown | last post by:
I'm telnetting into a router. Apart from the fact I can't seem to view the output when iniciating the session, I can't match one of the expressions using Net::Telnet. I can telnet into the router...
2
by: eight02645999 | last post by:
hi i am using a telnet session to simulate an authentication mechanism USER = "user" PASSWORD = "password" try: telnet = telnetlib.Telnet(HOST) telnet.set_debuglevel(5)...
2
by: thilandeneth | last post by:
i need to do telnet via a web server please give me a idia to initiate the project following requirements are needed 1 Create web based custom telnet client to communicate with remote...
1
by: perlxyo999 | last post by:
Hi , I have a problem doing manipulation (like split) in string comeing back from telnet commnd : $HOST = 'xxx'; $USER = 'yyy20'; $PASS = 'yyy-pass'; #$telnet = Net::Telnet->new($HOST);...
8
by: ivabigun | last post by:
Hi guys im trying to telnet to an IP address that is entered into a textbox from the click of a button but im having problems as it just gives me errors when i run it. Here is my code: Private Sub...
6
by: sherrygomindes | last post by:
Hi I have written a perl script using the Telnet module. I need to remotely login in from one windows XP machine to another XP machine. But i get errors which i can't figure out the reason....
17
by: ravimath | last post by:
Dear all, I have written following script to loin to router bu it is showing error. #!c:\Perl\bin; use strict; use warnings; my $hostname = 'REMOVED FOR YOUR PROTECTION'; my $password =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.