Solved

How to create  a shell script to automate telnet?

Posted on 1997-11-17
2
426 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

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…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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.

770 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