Solved

How to create  a shell script to automate telnet?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

947 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

20 Experts available now in Live!

Get 1:1 Help Now