#!/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(); #### user@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