* * *

Author Topic: Telnet Client  (Read 456 times)

nugax

  • Jr. Member
  • **
  • Posts: 72
Telnet Client
« on: February 14, 2018, 10:18:31 pm »
Does anyone know of a simple telnet client code or project that might already be done?

Or... does Free Pascal have any units already available for use to make a telnet client?
-Nugax

eric

  • Sr. Member
  • ****
  • Posts: 261
Re: Telnet Client
« Reply #1 on: February 14, 2018, 11:44:13 pm »

nugax

  • Jr. Member
  • **
  • Posts: 72
Re: Telnet Client
« Reply #2 on: February 15, 2018, 10:47:08 pm »
-Nugax

rvk

  • Hero Member
  • *****
  • Posts: 3151
Re: Telnet Client
« Reply #3 on: February 15, 2018, 10:51:08 pm »
Where do you get:
tlntsend.pas
If you are using Laz 1.8 you can use Online Package Manager to download and install Synapse 40.1
(Package > Online Package Manager)

Otherwise you can download it from
https://sourceforge.net/p/synalist/code/HEAD/tree/trunk/
(Download at top right)

nugax

  • Jr. Member
  • **
  • Posts: 72
Re: Telnet Client
« Reply #4 on: February 15, 2018, 11:16:13 pm »
I found it. I am trying to get a simple telnet conenction out to port 23, and keep getting access violations.

Code: Pascal  [Select]
  1. unit telnet_bbs;
  2.  
  3. {$I direct.inc}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, telnetsshclient;
  9.  
  10. procedure connect_test();
  11.  
  12.  
  13. implementation
  14.  
  15. procedure connect_test();
  16. Var
  17.   comm : TTelnetSSHClient;
  18.   Command: string;
  19.  
  20. Begin
  21.  
  22.   comm.Create;
  23.   comm.hostname := 'bbs.thebytexchange.com';
  24.   comm.TargetPort:= '23';
  25.   writeln(comm.Connect); //Show result of connection
  26. end;
  27.  
  28.  
  29.  
  30. //Main Program Code
  31. Begin
  32.  
  33. end.    
-Nugax

nugax

  • Jr. Member
  • **
  • Posts: 72
Re: Telnet Client
« Reply #5 on: February 15, 2018, 11:16:49 pm »
Maybe you cant  do it this way, i dont know. I followed the directions of synapse.
-Nugax

rvk

  • Hero Member
  • *****
  • Posts: 3151
Re: Telnet Client
« Reply #6 on: February 15, 2018, 11:19:29 pm »
Code: Pascal  [Select]
  1.   comm.Create;
comm.Create; is wrong. It does not create the object. It calls Create from an uninitialized object.
You should use
Code: Pascal  [Select]
  1. comm := TTelnetSSHClient.Create;

B.T.W. the example program in the wiki shows that clearly.

Code: Pascal  [Select]
  1. uses
  2.   telnetsshclient;
  3. var
  4.   comm: TTelnetSSHClient;
  5.   Command: string;
  6. begin
  7.   writeln('Starting.');
  8.   comm:=TTelnetSSHClient.Create;
  9.   comm.HostName:= ParamStr(1); //First argument on command line
  10.   if comm.HostName='' then
  11.   begin
  12.     writeln('Please specify hostname on command line.');
  13.     halt(1);
  14.   end;

nugax

  • Jr. Member
  • **
  • Posts: 72
Re: Telnet Client
« Reply #7 on: February 15, 2018, 11:21:39 pm »
Oops. Missed that. That worked, didnt get anything back from the writeln though.



Code: Pascal  [Select]
  1.   comm.Create;
comm.Create; is wrong. It does not create the object. It calls Create from an uninitialized object.
You should use
Code: Pascal  [Select]
  1. comm := TTelnetSSHClient.Create;

B.T.W. the example program in the wiki shows that clearly.

Code: Pascal  [Select]
  1. uses
  2.   telnetsshclient;
  3. var
  4.   comm: TTelnetSSHClient;
  5.   Command: string;
  6. begin
  7.   writeln('Starting.');
  8.   comm:=TTelnetSSHClient.Create;
  9.   comm.HostName:= ParamStr(1); //First argument on command line
  10.   if comm.HostName='' then
  11.   begin
  12.     writeln('Please specify hostname on command line.');
  13.     halt(1);
  14.   end;
-Nugax

rvk

  • Hero Member
  • *****
  • Posts: 3151
Re: Telnet Client
« Reply #8 on: February 15, 2018, 11:30:14 pm »
That worked, didnt get anything back from the writeln though.
Maybe because the ftp expects a username and password.
It's best to just take the complete example and strip out what you think you don't need.

I take it the ftp does need a username and password, doesn't it?

nugax

  • Jr. Member
  • **
  • Posts: 72
Re: Telnet Client
« Reply #9 on: February 15, 2018, 11:31:05 pm »
Its telnet not ftp.

And, it displays ansi, etc, then asks for input.

its not just normal telnet.
-Nugax

rvk

  • Hero Member
  • *****
  • Posts: 3151
Re: Telnet Client
« Reply #10 on: February 15, 2018, 11:36:52 pm »
Its telnet not ftp
Woops, yeah, where was I with my thoughts :)

It should just connect.

rvk

  • Hero Member
  • *****
  • Posts: 3151
Re: Telnet Client
« Reply #11 on: February 15, 2018, 11:53:18 pm »
Did you set the protocol to telnet?
comm.ProtocolType := telnet;

The comm.connect should give you:
Quote
Connected to telnet server.
And the comm.WelcomeMessage should contain:
Quote
(U[?1000h Mystic BBS v1.12 A38 for Linux Node 1
Copyright (C) 1997-2017 By James Coyle

Detecting terminal emulation: 

Wow, a BBS system. That takes me back some years :D
« Last Edit: February 15, 2018, 11:59:08 pm by rvk »

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus