Solved

Programming of the Telnet protocol

Posted on 1997-11-21
7
240 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
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!

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

632 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