#!/usr/bin/perl use strict; use warnings; use IO::Socket; my $EOL = "\015\012"; my $mpts; ### Until I get cgi working. open OUT, "> testpage.html" or die("Unable to open output file: $!\n"); select(OUT); if (0) ### { local *HEADER; open HEADER, "< 1.html" or die("Unable to open header file: $!\n"); print while (
); close HEADER; } my $sock = new IO::Socket::INET( # PeerAddr => '53.230.116.97', PeerAddr => '127.0.0.1', ### PeerPort => '8888', Proto => 'tcp', ) or die("Error creating connnection: $!\n"); for (1..20) { my $command = "check cs2"; print $sock $command, $EOL; local $/ = $EOL; my $reply = <$sock>; die("Lost connection to server.\n") unless defined $reply; chomp($reply); if ($reply eq "up") { print STDERR "up\n"; print "\n"; $mpts++; } elsif ($reply eq "down") { print STDERR "down\n"; print "\n"; } else { die("Bad reply $reply\n"); } sleep(1); } close($sock); close(OUT);