 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
AntonE Guest
|
Posted: Sun May 06, 2007 5:47 am Post subject: TelNet client demo needed |
|
|
I need to login to a router (from Delphi app) and run some commands & get
their responses. Can anyone point me in the right direction? I'm using Indy
10's idTelNet component but do not know how to get responses back. No need
for user input, the app will know what to say.
Perhaps a demo app will get me going?
Thanks |
|
| Back to top |
|
 |
AntonE Guest
|
Posted: Sun May 06, 2007 8:11 am Post subject: Re: TelNet client demo needed |
|
|
Here is my problem:
idTelNEt1.Host:=IPS2IP(MikIP.AsString);
idTelnet1.Connect;
idTelNEt1.IOHandler.WriteLn(MikUserNAme.AsString);
idTelNEt1.IOHandler.WriteLn(MikPW .AsString);
idTelNEt1.IOHandler.WriteLn('system');
idTelNEt1.IOHandler.WriteLn('pack');
idTelNEt1.IOHandler.WriteLn('print');
but when the proc exit, I just get all the commands as if it was put into
the first prompt and at the end I get password prompt, which should be after
the username thingy...
BUT, if I make it:
idTelNEt1.Host:=IPS2IP(MikIP.AsString);
idTelnet1.Connect;
idTelNEt1.IOHandler.WriteLn(MikUserNAme.AsString);
(**) ShowMessage(IntToStr(idTelNet1.IOHandler.RecvBufferSize));
idTelNEt1.IOHandler.WriteLn(MikPW .AsString);
(**) ShowMessage(IntToStr(idTelNet1.IOHandler.RecvBufferSize));
....
then apart from the annoying popups, I get the router responses correctly in
OnDataAvailable...
Maybe some threading issue? idTelNet.ThreadedEvent=False |
|
| Back to top |
|
 |
theo Guest
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon May 07, 2007 10:54 pm Post subject: Re: TelNet client demo needed |
|
|
"AntonE" <antone (AT) true (DOT) co.za> wrote in message
news:463d2510 (AT) newsgroups (DOT) borland.com...
| Quote: | I'm using Indy 10's idTelNet component
|
Why? Router's rarely use Telnet to begin with. Usually HTTP, but
sometimes SNMP as well.
| Quote: | but do not know how to get responses back.
|
TIdTelnet has an OnDataAvailable event. But chances are, you should
be using TIdHTTP instead. It really depends on the particular type of
router you are using, and how users normally configure it by hand.
Gambit |
|
| Back to top |
|
 |
AntonE Guest
|
Posted: Tue May 08, 2007 12:58 am Post subject: Re: TelNet client demo needed |
|
|
It is a Mikrotik router (www.mikrotik.com) running on a routerboard
(www.routerboard.com) and yes, it has a http interface, but very limited,
only TelNet and propriety prog called WinBox can access full settings. If I
want to program externally, automatically, only option is Telnet.
Running a wireless network (all clients & APs have them) so if I need to
block a client or restrict speed, etc. etc. I need to do it manually as the
management software is written by me, but without TelNet, I cannot let my
app change router settings.
To get back to the point, please have a look at my post 'Telnet followup...'
on atozedsoftware.indy.client.tcp forum for more details, I think I'm almost
there but as a tradional DB developer, the whole Indy thing is new to me.
Thanks for the response
AntonE
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote in message
news:463f67c6$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
"AntonE" <antone (AT) true (DOT) co.za> wrote in message
news:463d2510 (AT) newsgroups (DOT) borland.com...
I'm using Indy 10's idTelNet component
Why? Router's rarely use Telnet to begin with. Usually HTTP, but
sometimes SNMP as well.
but do not know how to get responses back.
TIdTelnet has an OnDataAvailable event. But chances are, you should
be using TIdHTTP instead. It really depends on the particular type of
router you are using, and how users normally configure it by hand.
Gambit
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue May 08, 2007 2:13 am Post subject: Re: TelNet client demo needed |
|
|
"AntonE" <antone (AT) true (DOT) co.za> wrote in message
news:463f848a (AT) newsgroups (DOT) borland.com...
| Quote: | It is a Mikrotik router (www.mikrotik.com) running on a routerboard
(www.routerboard.com) and yes, it has a http interface, but very
limited, only TelNet and propriety prog called WinBox can access
full settings. If I want to program externally, automatically, only
option
is Telnet. Running a wireless network (all clients & APs have them)
so if I need to block a client or restrict speed, etc. etc. I need
to do
it manually as the management software is written by me, but without
TelNet, I cannot let my app change router settings.
|
Are you absolutely sure that it is using the Telnet protocol
specifically, or just plain TCP/IP in general?
Gambit |
|
| Back to top |
|
 |
AntonE Guest
|
Posted: Tue May 08, 2007 3:24 am Post subject: Re: TelNet client demo needed |
|
|
| Quote: | Are you absolutely sure that it is using the Telnet protocol
specifically, or just plain TCP/IP in general?
|
Well, I can log into it from Windows command prompt : "Telnet 10.1.12.12'
and then follow login & commands, etc.
If that is what you mean?
It is a Linux kernel based software that is loaded, you can also load Debian
on it, but I prefer the Mikrotik software because it is fantastic. I.o.w not
the usual router. I also have some DLink AP's (DWL-2000AP) which I sometimes
use Telnet on, but they wouldn't be involved in this issue.
I basically just need a way to tell Indy to 'tick-over' (lack of better
wording) as when I add a ShowMessage command (to pass control to the app
main thread(?)) between my idTelnet commands, all works ok, but just running
them in sequence causes the 'problem'.
AntonE |
|
| Back to top |
|
 |
AntonE Guest
|
Posted: Tue May 08, 2007 3:32 am Post subject: Re: TelNet client demo needed |
|
|
| Quote: | Are you absolutely sure that it is using the Telnet protocol
specifically, or just plain TCP/IP in general?
|
The manual also state Telnet as being the interface of choice and if you
have a look at the other post I mentioned, you'll see that I get some good
results with idTelnet, I just need to be able to do it all in one proc,
without getting into threading and stuff as I've never threaded before and
this part of the app is really so simple.
Thanks for the reply
AntonE |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue May 08, 2007 3:48 am Post subject: Re: TelNet client demo needed |
|
|
"AntonE" <antone (AT) true (DOT) co.za> wrote in message
news:463fa6c6 (AT) newsgroups (DOT) borland.com...
| Quote: | Well, I can log into it from Windows command prompt :
"Telnet 10.1.12.12' and then follow login & commands, etc.
|
That does not mean that the Telnet protocol specifically is being
used, though. You can use the Telnet app to connect to any TCP-based
system. But the Telnet protocol itself is a specific type of
TCP-based protocol, and thus has its own rules about how data is
exchanged between client and server. Unless the system is actually
using the Telnet protocol, then those rules may corrupt your data
and/or cause hangs/crashes.
I suggest you using TIdTCPClient directly instead of TIdTelnet until
you determine exactly what protocol the router is really using.
Chances are, it will not be using the actual Telnet protocol at all.
| Quote: | It is a Linux kernel based software that is loaded
|
That is irrelevant. Th OS does not matter in this situation.
Gambit |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue May 08, 2007 3:49 am Post subject: Re: TelNet client demo needed |
|
|
"AntonE" <antone (AT) true (DOT) co.za> wrote in message
news:463fa87c (AT) newsgroups (DOT) borland.com...
| Quote: | The manual also state Telnet as being the interface of choice
|
Telnet the PROGRAM or Telnet the PROTOCOL, though? There is a big
difference. What EXACTLY does the manual say about all of this?
| Quote: | if you have a look at the other post I mentioned, you'll see that I
get some good results with idTelnet, I just need to be able to do
it all in one proc
|
Then you shouldn't be using TIdTelnet, as that is not how it was
designed to be used. Use TIdTCPClient directly instead.
Gambit |
|
| Back to top |
|
 |
AntonE Guest
|
Posted: Tue May 08, 2007 4:32 am Post subject: Re: TelNet client demo needed |
|
|
| Quote: | Telnet the PROGRAM or Telnet the PROTOCOL, though? There is a big
difference. What EXACTLY does the manual say about all of this?
|
This is what I could find:
MikroTik RouterOS has a build-in Telnet server and client features. These
two are used to
communicate with other systems over a network.
....
Telnet protocol is intended to provide a fairly general, bi-directional,
eight-bit byte oriented
communications facility. The main goal is to allow a standard method of
interfacing terminal
devices to each other.
MikroTik RouterOS implements industry standard Telnet server. It uses port
23, which must not be
disabled on the router in order to use the feature.
You can enable/disable this service or allow the use of the service to
certain IP addresses.
| Quote: | Then you shouldn't be using TIdTelnet, as that is not how it was
designed to be used. Use TIdTCPClient directly instead.
|
Being a newcommer to TCP stuff, would you be so kind as to explain how I can
then do this talk/listen idea or just point me to a demo of some sort. |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue May 08, 2007 6:35 am Post subject: Re: TelNet client demo needed |
|
|
"AntonE" <antone (AT) true (DOT) co.za> wrote in message
news:463fb6b2 (AT) newsgroups (DOT) borland.com...
| Quote: | MikroTik RouterOS has a build-in Telnet server and client features.
|
Fair enough.
| Quote: | Being a newcommer to TCP stuff, would you be so kind as to
explain how I can then do this talk/listen idea
|
I explained that in reply to your messages in the Indy newsgroups.
Gambit |
|
| Back to top |
|
 |
theo Guest
|
Posted: Tue May 08, 2007 2:49 pm Post subject: Re: TelNet client demo needed |
|
|
| Quote: |
Being a newcommer to TCP stuff, would you be so kind as to explain how I can
then do this talk/listen idea or just point me to a demo of some sort.
|
I'm still convinced that Synapse is better suited for this kind of job.
It's a simple write-read-write-read.. scenario.
This is exactly how Synapse works. See:
http://synapse.ararat.cz/docs/help/tlntsend.TTelnetSend.html
You really don't need events and threads for this. |
|
| Back to top |
|
 |
AntonE Guest
|
Posted: Tue May 08, 2007 10:52 pm Post subject: Re: TelNet client demo needed |
|
|
Thanks toby. I tried it, but I only get first line after 'login' command
back, after that no 'response' from server.
procedure TForm1.BitBtn1Click(Sender: TObject);
var TN : TTelnetSend;
begin
TN:=TTelnetSend.Create;
TN.TargetHost:='10.1.12.12';
TN.TargetPort:='23';
TN.Timeout:=1000;
TN.Login;
Memo1.Lines.Add(TN.RecvString);
TN.Send('admin');
Memo1.Lines.Add(TN.RecvString);
TN.Send('blah');
Memo1.Lines.Add(TN.RecvString);
TN.Send('sys');
Memo1.Lines.Add(TN.RecvString);
TN.Send('pack');
Memo1.Lines.Add(TN.RecvString);
TN.Send('pr');
Memo1.Lines.Add(TN.RecvString);
TN.Logout;
end; |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed May 09, 2007 12:03 am Post subject: Re: TelNet client demo needed |
|
|
"AntonE" <antone (AT) true (DOT) co.za> wrote:
| Quote: | Thanks toby. I tried it, but I only get first
line after 'login' command back, after that no
'response' from server.
|
Does Send() automatically send a CRLF at the end of the string? Sounds like it doesn't, but the server is likely expecting that.
Gambit |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|