Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Telnet Scripting Question

Posted on 2008-10-31
7
Medium Priority
?
664 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
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 35

Accepted Solution

by:
Duncan Roe earned 750 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month9 days, 14 hours left to enroll

926 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