#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket;
my $server = "remote.server.net";
my $port = 43;
my $path = "/";
my $socket=IO::Socket::INET->new(
PeerAddr => $server,
PeerPort => $port,
Proto=> 'tcp') ||
die "Can't connect to $server:$port: $!\n";
my $data = qq~GET $path HTTP/1.1
Host: $server
Accept: */*
User-Agent: My Perl Script
Pragma: no-cache
Cache-Control: no-cache
Connection: close
~;
print $socket "$data\r\n";
my $body = 0;
while(<$socket>) {
my $line = $_;
if ($body eq 1) {
print $line;
}
$body = 1 if ($line=~/Connection: close/i);
}
close($socket);
####
#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket;
my $remote_server = "ftp.server.net";
my $remote_port = 21;
my $sock = IO::Socket::INET->new("$remote_server:$remote_port") || die $!;
my $data = "HELP";
my $string_to_compare = "^220 ";
print $sock "$data\r\n";
my @output;
$| = 1;
while (<$sock>) {
push(@output, $_);
print $sock "QUIT\n" if /$string_to_compare/gi;
}
close($sock);
my $output = join('', @output);
sub true {
print "Ain't dat da true! :o)\n";
# open(tmpl, "email.txt") || print $!;
}
sub false {
print "Close, but no banana.\n";
}
if ($output =~ /$string_to_compare/gi) {
&true;
} else {
&false;
}
####
$| = 1;
####
my @output = <$sock>;
####
$output = join('', @output);