Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Script to establish telnet connection and output results to text file

Posted on 2007-11-19
2
Medium Priority
?
4,394 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 2000 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

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

730 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