Telnet Automation How to?

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2004
Posts: 219
Reputation: BountyX is an unknown quantity at this point 
Solved Threads: 7
BountyX's Avatar
BountyX BountyX is offline Offline
Code Guru

Telnet Automation How to?

 
0
  #1
Mar 31st, 2004
I got this big problem. I have to automate a Telnet connection for this project but I have no idea on how to do that in C/C++ . I need to be able to send an ascii file's contents (1 command per line) so that it will automate those commands. Then I need to save the output in a text file, and have the program analyze it. Finally i have to repeat the process automatically for the next ip in line.

If this can be done all automatically already with an exsisting program, could you please direct me to it?

Any help is greatly appreciated!
A Hacker's Mind:
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes..." - J.D.Salinger
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 8
Reputation: Aaerox is an unknown quantity at this point 
Solved Threads: 1
Aaerox Aaerox is offline Offline
Newbie Poster

Re: Telnet Automation How to?

 
0
  #2
Mar 31st, 2004
Open winsock on port 23, then just send the data away. Assuming you'll get a reply for every telnet command you send, you can just use blocking winsock commands in a loop.
i.e:

  1. readdata(Filename, CommandArray)
  2. initwinsock()
  3. for (int x=0;x<UpperBound(IPList);x++)
  4. {
  5. connect(ip)
  6. for (int i=0;i<UpperBound(CommandArray);i++)
  7. {
  8. send(CommandArray[i])
  9. recv(RecieveBuffer)
  10. handlebuffer(RecieveBuffer)
  11. }
  12. }
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 77
Reputation: infamous is an unknown quantity at this point 
Solved Threads: 2
infamous infamous is offline Offline
Junior Poster in Training

Re: Telnet Automation How to?

 
0
  #3
Mar 31st, 2004
you need to make sure u terminate everything u send with "\r\n", or telnet server wont recognize it. and u'll need to login properly, i'd check out part of the telnet RFC, or try and google for a quick telnet tutorial; as well as sniffing your own traffic on a few sessions - that is one of best ways to write a quick prog that actually works. another option, would be to use the Expect scripting language, quite handy for things liek this: http://expect.nist.gov/
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC