ATB has asked for the wisdom of the Perl Monks concerning the following question:
I just realized that LWP::Simple might do the same trick, but as I am so close to getting this to work, I'd rather do it this way if I'm missing something simple.
I do realize that my unless statement is pretty pointless, as it performs the send() method whether it times out or not. I'm pretty sure that isn't my problem though. :)
Also, the GET command does work w/o the script.
Here is the output when I run aforementioned code:#!/usr/local/bin/perl -w use Expect; $command = "telnet xxx.xx.xx.xx 80"; $timeout = 5; $match = "Escape character is '^]'."; my $exp = Expect->spawn( $command ) or die "cannot spawn $command: $!\ +n"; unless ($exp->expect($timeout, $match)) { print "Error: host timed out\n"; } $exp->send("GET /dir/index.html HTTP/1.0 \r\r"); $exp->soft_close();
Thanks in advance. -vuser@host> ./program Trying xxx.xx.xx.xx... Connected to xxx.xx.xx.xx. Escape character is '^]'. GET /dir/index.html HTTP/1.0 HTTP/1.0 400 Bad Request
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using Expect mod to telnet to port 80 (HTTP)
by pfaut (Priest) on Dec 30, 2002 at 22:44 UTC | |
by ATB (Initiate) on Dec 30, 2002 at 23:02 UTC | |
|
Re: Using Expect mod to telnet to port 80 (HTTP)
by Aristotle (Chancellor) on Jan 04, 2003 at 15:18 UTC |