Article 53067 of comp.lang.perl.misc:
Path: matra.meer.net!news.spies.com!nntp1.jpl.nasa.gov!news.magicnet.net!feed1.news.erols.com!howland.erols.net!EU.net!news.bbnplanet.com!cpk-news-hub1.bbnplanet.com!cpk-news-feed4.bbnplanet.com!sc.edu!usenet
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
Newsgroups: comp.lang.perl.misc
Subject: Re: Telnet Redirecting Input
Date: 26 Nov 1996 19:56:58 -0500
Organization: Univ. of South Carolina, Columbia
Lines: 42
Message-ID: <x0682spd7p.fsf@tbone.biol.sc.edu>
References: <32989d4d.3040806@news.pipex-sa.net> <329AC518.446B@flnet.nl>
NNTP-Posting-Host: tbone.biol.sc.edu
X-Newsreader: Gnus v5.3/Emacs 19.33

Rob J Meijer <rob@flnet.nl> writes:
> Andrew Myers wrote:
> > Hi
> >    I am trying to write a program that will do so analysis on a file.
> > 
> >    I want to telnet to a machine (web server) and go to port 80
> >    and send a command say "GET / HTTP/1.0" for exaple
> >    followed by two lines and then grab the output into a file
> 
> You shouldn't be thinking telnet, you should be thinking TCP and
> sockets
...

> Here you have a litle old perl program of mine that might help you
> on your way, its a litle rude, and was written for perl4, not sure
> if it works ok witk perl5 but should help you on your way.  You
> should also look into $AF_INET and $SOCK_STREAM, on a IRIX machine
> their both 2, but it might differ on different other systems,
> $SOCK_STREAM is 1 on many other systems like SUN and Linux.
[code elided]

Don't do it.  Check the following two modules: Socket and LWP.  Socket
takes care of all the machine-specific things, so you don't need to do
Evil Pernicious Hard Coding of Constants.  The LWP library contains
everything you'd need to do what you want.  How about:

perl -MLWP::Simple -e 'getprint "http://www.whatever.com"' > junk

as a oneliner that does the job.  And, of course, there are oodles of
more complex things you can do. 

Modules are available via CPAN, which you can find at
<URL:http://www.perl.com/perl>.  Look for Software, then the "full
modules list".  Browse that, seach for LWP and Socket, and follow
links to the software.

-Dean
-- 
N. Dean Pentcheff   <pentcheff@acm.org>   WWW: http://tbone.biol.sc.edu/~dean/
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-3936)
PGP ID=768/22A1A015 Keyprint=2D 53 87 53 72 4A F2 83  A0 BF CB C0 D1 0E 76 C0 
Get PGP keys and information with the command: "finger dean@tbone.biol.sc.edu"


