Solved

Script to establish telnet connection and output results to text file

Posted on 2007-11-19
2
4,392 Views
Last Modified: 2008-02-01
I'm looking to create a script that will do the following:

Connect to several devices (one by one) via telnet, send a couple of commands and save *only* the output of 'status line x' and 'detail line x' to a text file.

To give a better idea, this is what the telnet connection looks like:


~~~~~~~~~~~~~~~~~~~~~~~~

telnet 192.168.1.55
--welcome message --
password prompt > ****** ('password' should be entered by the script)

prompt > status (this 'status' command should be sent by the script)

--status line 1--
--status line 2--
--status line 3--
--status line 4--

prompt > showdetail (this 'showdetail' command should be sent by the script)

--detail line 1--
--detail line 2--
--detail line 3--

prompt > exit

~~~~~~~~~~~~~~~~~~~~~~~~


In the end the output text file should look something like this:

---

device ip: 192.168.1.55
status line 1
status line 4
detail line 3

device ip: 192.168.1.56
status line 1
status line 4
detail line 3

etc...
---
0
Comment
Question by:impersonator
[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
2 Comments
 
LVL 38

Accepted Solution

by:
Shift-3 earned 500 total points
ID: 20316118
I'm fairly certain there is no built-in way to do this in Windows (though if there is I'd love to hear about it).

However it should be possible to do it using the free client PuTTY.
http://www.chiark.greenend.org.uk/~sgtatham/putty

It includes a command-line tool called Plink which supports batch scripting.
http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter7.html#plink
0
 

Author Comment

by:impersonator
ID: 20637050
I had already found plink before posting :o).  I ended up using a batch script that calls Expect (http://expect.nist.gov/) + plink to connect to the telnet server then saves the output to a temporary text file which later gets parsed to create the output I want.

thanks.
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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

627 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