Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to open a telnet session using C?

Posted on 2003-11-12
11
Medium Priority
?
345 Views
Last Modified: 2008-02-26
In Perl, I learned to use the Net::Telnet module. It includes the following commands: login, waitfor, print cmd, close.

Is there a telnet library in C with the equivalent commands? How do I use them?
0
Comment
Question by:elvin226
[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
  • 4
  • 3
  • 2
11 Comments
 
LVL 8

Expert Comment

by:ssnkumar
ID: 9737536
For doing this in C, you will have to write your own code using socket programming.
The commands you will be using are socket(), bind(), listen(), accept(), send() and receive().
So, the first thing is to learn socket programming!:-)
But, both windows and Unix provide telnet program. Why don't you use this itself!?

In C, you can call telnet using the following statement: system("telnet ip_addr");
Or you can use exec() to do the same.

Hope I answered your question....
0
 
LVL 8

Assisted Solution

by:ssnkumar
ssnkumar earned 600 total points
ID: 9737563
For doing this in C, you will have to write your own code using socket programming.
The commands you will be using are socket(), bind(), listen(), accept(), send() and receive().
So, the first thing is to learn socket programming!:-)
But, both windows and Unix provide telnet program. Why don't you use this itself!?

In C, you can call telnet using the following statement: system("telnet ip_addr");
Or you can use exec() to do the same.

Hope I answered your question....
0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 600 total points
ID: 9737564
A seesion can be initiated with
system ( "telnet ... ");
or by
fork()
followed by exec()....

for full library, have a look at TCPware
http://vms.process.com/ftp/tcpware/documentation/html/programmer/httoc.htm
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:elvin226
ID: 9745069
What I'm trying to do is an automated telnet script, not interactive, so I can't use system("telnet"). The program will be the one to send messages, not the user, and it has to wait for the remote machine's response before sending another message.
0
 
LVL 8

Expert Comment

by:ssnkumar
ID: 9745116
If you want a interactive telnet session, then you will have to write the complete program!
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9745364
download the telent library ... it provides the API do the work ...
If you wish to do it with script, then use expect
http://expect.nist.gov/

using them, you wont have to write the whle code
0
 

Author Comment

by:elvin226
ID: 9745452
sunnycoder,

what I'm asking for is the C library for telnet and examples of how to use it's functions...if there exists one.

I've already done it with Perl, now I want to learn how to do it in C.
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9745583
take a look at any telent client coded in C
http://www.sofotex.com/download/Networking/Telnet/more3.html
http://linux.tucows.com/preview/220521.html
http://www.ararat.cz/synapse/

you would be having one with your own linux distribution too !!! tucows site has lots of clients ... search it for more info
0
 
LVL 8

Expert Comment

by:ssnkumar
ID: 10400537
I too deserve points!:-))

-ssnkumar
0

Featured Post

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!

Question has a verified solution.

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Suggested Courses

618 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