Solved

Telnet Scripting Question

Posted on 2008-10-31
7
657 Views
Last Modified: 2012-05-05
I have a weather system with an RS232 port that you can run queries and get the current temperature.  I recently installed fogsoft.com's Serial/IP server that basically acts as a telnet to rs232 bridge.  I am wanting to run a script twice a day that will telnet to the device, run some commands, and save the output to a file.   I will then email that file twice a day as well.

To get it to work manually, I have to run the following commands:

1. telnet
2. set escape ?  (could be anything but ? was the easiest)
3. open example.domain.com 2000  (uses port 2000 for telnet)
4. ?  (? key switches back to telnet> )
5. mode character (this server only supports character mode, without this, the results are never displayed)
6. atn

Once your type atn and press enter, it displays the current temperature.

I have spent hours trying to dig through scripting examples, but can never get past the part where it connects to the server.

This is what I have so far:

( echo "?"
sleep 1
echo "mode character"
sleep 1
echo -e "\r"
sleep 1
echo "atn"
sleep 1
echo -e "\r"
sleep 1
sleep 10
) | telnet -e ? vpn.alpinecomm.com 2000


Any thoughts?  Your help is much appreciated!


Brandon M.
0
Comment
Question by:renvorak
[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
7 Comments
 
LVL 8

Expert Comment

by:Rance_Hall
ID: 22854190
Ive never had much success with bash against things like ftp and telnet, yes there are ways to do it, but in my limited experience they were kludges at best and not easily portable across boxes.

in come scripting languages with modules specifically designed for telnet

like kermit, or some of the specific modules of php, python, perl, etc.

I have personal experience with php and kermit, but any of the modern scripting languages can help you.
0
 
LVL 1

Expert Comment

by:d4t2ill4
ID: 22854221
0
 
LVL 1

Expert Comment

by:d4t2ill4
ID: 22854230
0
 
LVL 34

Accepted Solution

by:
Duncan Roe earned 250 total points
ID: 22872519
The classic way to run telnet in a script is to use expect. The documentation has a telnet login as an example.
http://expect.nist.gov/
0
 
LVL 1

Author Closing Comment

by:renvorak
ID: 31512200
Partially worked, but got me on the right track.
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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

738 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