943,556 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 20373
  • C++ RSS
Mar 31st, 2004
0

Telnet Automation How to?

Expand Post »
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!
Similar Threads
Reputation Points: 28
Solved Threads: 9
Posting Whiz in Training
BountyX is offline Offline
222 posts
since Mar 2004
Mar 31st, 2004
0

Re: Telnet Automation How to?

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:

C++ Syntax (Toggle Plain Text)
  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. }
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Aaerox is offline Offline
8 posts
since Mar 2004
Mar 31st, 2004
0

Re: Telnet Automation How to?

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/
Reputation Points: 47
Solved Threads: 2
Junior Poster in Training
infamous is offline Offline
77 posts
since Mar 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Preventing Hooks
Next Thread in C++ Forum Timeline: pausing a command





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC