a script using telnet to retrieve a single html-file?

a script using telnet to retrieve a single html-file?

Post by Lemponen Ol » Thu, 16 Jul 1998 04:00:00



I know how to retrieve a html-document using telnet manually, but how can
I do it using a script? I tried but couldn't get it to work correctly.
I'm using Bash.

Here's what I tried:
telnet < script-file >& html-file

my 'script-file' was:
-- begin file --
open www.foo.com
GET /index.html HTTP/1.0

-- end file --

I know the aswer should be simple, but I'm kinda new to this stuff so...

Thanks in advance,
Olli Lemponen
---
                You know you've achieved perfection in design,
                    Not when you have nothing more to add,
                 But when you have nothing more to take away.

                         Antoine de Saint Exupery

 
 
 

a script using telnet to retrieve a single html-file?

Post by Jeffrey R. Dru » Thu, 16 Jul 1998 04:00:00


[ posted to comp.unix.shell and a courtesy copy was mailed to the cited author
]


Quote:>I know how to retrieve a html-document using telnet manually, but how can
>I do it using a script? I tried but couldn't get it to work correctly.
>I'm using Bash.

>Here's what I tried:
>telnet < script-file >& html-file

>my 'script-file' was:
>-- begin file --
>open www.foo.com
>GET /index.html HTTP/1.0

>-- end file --

>I know the aswer should be simple, but I'm kinda new to this stuff so...

Telnet expects its input from a tty, not STDIN, so this just won't work. You'll
need a tool such as Perl or Expect to do this sort of thing. In recent versions
of Perl, it's as simple as:

$ perl -MLWP::Simple -e 'getprint "http:://www.hostname.com/index.html"'

Don Libes' Expect is designed to actually simulate tty input for scripted FTP
and telnet sessions, and certainly allows you to get what you're looking for.
Unfortunately, it seems you have to work a little harder at it . . .

--
                               Jeffrey R. Drumm, Systems Integration Specialist
                       Maine Medical Center - Medical Information Systems Group

"Broken? Hell no! Uniquely implemented!" - me

 
 
 

1. Using expect to retrieve an html file via telnet - ?

Thanks to all of you who responded to my 'nobody' question.
I solved the problem by setting write permission on the file
to 'group' (come to find out, 'nobody' was in my group).

Does anyone know how to use expect to retrieve an html file from a
server via telnetting to port 80?

When I do it from the command line, it's:

 telnet any.site.com 80

 GET /some/path/here/some_file.html

The man pages for expect weren't all that helpful.

I gathered that it's something like the following:

  spawn telnet any.site.com 80
  sleep 5
  send "GET /some/path/here/some_file_html"

  After that, I'm stumped. How would I get the output from the
  server into a file?

  Thanks.

  - Xochi

--
| Xochi Zen        "William James used to preach the 'will to believe.' For   |

|                   What is wanted is not the will to believe, but the wish to|
|                   find out, which is the exact opposite" - Bertrand Russell |

2. Deleting directory

3. default file not index.html or parse a single file??

4. setserial - Wrong ioctl for serial port!?

5. How to retrieve a single file from a tar tape

6. INIT Problem

7. HELP with retrieving .html file to a unix box

8. FTP security problem

9. How to redirect html requests to a single cgi script

10. Retrieving images over HTTP using a telnet coprocess in ksh (!)

11. Apache 1.1.1: Limiting access to single HTML file

12. Copy files using filenames from text files with shell script or bash script

13. file.html and file.html/ give same thing