Solved

How to create  a shell script to automate telnet?

Posted on 1997-11-17
2
408 Views
Last Modified: 2008-02-26
While I am login in my shool Unix system. I'd like
to do use telnet to get homepage, for example "telnet
cnn.com 80" "GET /index.html HTTP/1.0\n\n" This works.
But if I put "GET /index.html HTTP/1.0\n\n" into a
file . and do "telnet cnn.com 80<afile", this won't work.
Why?
Thanks
0
Comment
Question by:xzhang
2 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 2007844
If you have expect
expect -c 'spawn telnet cnn.com 80; expect "Connected"; send "GET /index.html HTTP/1.0\r\r"; expect "Connection closed"'
0
 
LVL 1

Accepted Solution

by:
dhughes111797 earned 20 total points
ID: 2007845
telnet is an interactive program. It expects input from a terminal attached device (tty). As ozo said, you can use
a program like expect that acts like a modem chat script to
'expect' something and then 'send' something else. You cannot
make telnet take input from a file (or ftp for that matter -
thought ftp does have a .netrc that you can do some things
with)
expect - ftp.cme.nist.gov
(requires Tcl - ftp.smli.com)

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now