Solved

Programming of the Telnet protocol

Posted on 1997-11-21
7
239 Views
Last Modified: 2013-12-26
Dear all,

  I would like to write a program to telnet to another server.  However, I don't know what the command sequence is.
For example, when I can connect to the server with the port 23, then what command I will receive and what command I should send so that I can receive the 'login: " prompt?

Thanks!

Benson
0
Comment
Question by:benson031397
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 1

Expert Comment

by:dhughes111797
ID: 1295672
The machine on the other end must be running a telnet daemon program. This is a program that listens for a connection and
then exchanges some setup parameters with the client program that you run. When it authenticates you against the remote machine, it passes off the connection to a shell.

Most of the time, telnetd is run from a program called inetd. Take a look at the process table of the remote system and see if inetd is running. The file /etc/inetd.conf has the information about what daemons are run, and usually one of the linese in there is for telnetd.  It is perfectly reasonable for a site
to disable telnetd for security reasons - (plain text passwords
are a security risk)

If you do not receive a login prompt, and instead get something
like 'connection refused' when telneting to a remote machine,
then telnetd has been disabled on that machine. You do not
need to give a special port number to get the default behavior.

0
 

Author Comment

by:benson031397
ID: 1295673
The telnetd is absolutely enabled as I can type telnet to that server.  But now I think I have sent wrong init command sequence.
Can any experts give me the right init command sequence?
0
 
LVL 1

Expert Comment

by:dhughes111797
ID: 1295674
It would help if you supply OS information (name and revision)
and possibly hardware type if applicable.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:benson031397
ID: 1295675
Do u know what is telnet protocol?  My question is that what the init command sequences I will receive or should send after connecting the any unix server(with the daemon or protocol of telnet) with the port of 23.  I think the telnet protocol is independent of what the version of OS or name.  It just depends on whether the OS will use telnet protocol or not to receive the telnet request.


Thanks!
0
 

Accepted Solution

by:
philipm earned 30 total points
ID: 1295676
while many client/server programmers will tell you to use the LWP module in perl for such a thing, I recommend using Expect, a language based on Tcl/Tk for doing such things (ftp, telnet http).  It is very easy to use.  The best and quickest way to become familiar with Expect is to read the inventor of Expect's book on the language which is available on O'Reilly.

Here is an example program:

#!/usr/local/bin/expect --
spawn telnet netcom.com
expect "ogin:"
send "your_login\r"
expect "assword:"
send "your_password\r"
expect ">"
interact

This will open the telnet program to connect to netcom.com. Then it will wait for the appropriate strings and send the correct responses. The command 'interact' gives control back to the user.

You would want to make sure the response strings work for the server you are connected too for it too work properly.  

The main reason Expect is so useful is that it can be programmed to respond to a variety of responses, and it can have a timeout set to only let a query attempt run for so long

0
 

Author Comment

by:benson031397
ID: 1295677
Dear sir,

 It is a good answer.  But I want to do it by using socket programming becasue I would like to use Java or C to implement the telnet protocol

thanks!
Benson
0
 

Expert Comment

by:happynetguy
ID: 1295678
I think you should read the RFCs about telnet protocol carefully.
Or you can read the telnet souce code of Linux.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Expand macro to ask for filename column 8 40
move a line in eclipse 3 111
NotAlone Challenge 20 93
Not needed 13 134
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question