Solved

How to create  a shell script to automate telnet?

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

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

Suggested Solutions

Title # Comments Views Activity
ftpcommand 2 82
Where to get php 5.6 for AIX 7.1? 5 147
NTP Server in VMware 5 460
comm diff cmp unix commands 2 16
Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
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 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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

732 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