Archive for the ‘Perl’ Category

batch checking the apache version in local network

use IO::Socket::Telnet; use Parallel::ForkManager; use Net::Ping; my $pm=new Parallel::ForkManager(200); foreach (3..250){ my $host = ’192.169.1.’ . $_ ; $pm->start and next; if ( my $socket = IO::Socket::Telnet->new(PeerAddr => $host . ‘:80′, timeout => 1)){ #$socket->send(scalar ); $socket->send(“get\n\n”); defined $socket->recv(my $x, 4096) or die $!; $x =~ /address\>(.*)Server/; print “Host: $host Apache version: $1\n” ; }#$pm->run_on_wait; [...]

perl log rotate

use strict; use POSIX qw(strftime); use File::Copy; use File::Path; my $now_string = strftime “%H%M%m%d%Y”, localtime; #backup log file copy(“LogWriterLog.txt”,”LogWriterLog$now_string.txt”); #clean up log file open DATA, “+>LogWriterLog.txt” or die “Couldn’t open file file.txt, $!”; close(DATA) || die “Couldn’t close file properly”;

net::smtp 163 send email

use Net::SMTP; use Net::Domain qw(hostname); use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use MIME::Base64; $year = (0..99) [(localtime) [5]%100]; $year = sprintf (“20%02d”, $year); $thismonth = (1..12) [(localtime) [4]]; $thismonth = sprintf (“%02d”, $thismonth); $today = (0..31) [(localtime) [3]]; $today = sprintf (“%02d”, $today); $hour = (0..23) [(localtime) [2]]; $hour = sprintf (“%02d”, $hour); $min [...]

试试访问速度?