#!/usr/local/bin/perl # # ver. 09.02.2000 /1 for statistics format 1.00 # # Pavel Yakovlev, hac@Felist.Com # # Skeleton of the script for automatic taking of list statistics # http://Felist.Com/author/robostat.pl # # For work the installed libwww-perl # with CPAN http://www.perl.com/CPAN/ is required # # Call: robostat.pl list.id # Return code: 0 - successful # 1 - other problems # 2 - statistics taking error # 3 - unsupported version of statistics # # Without modification this script gives statistics to STDOUT # use strict; use integer; use LWP::UserAgent; $|=0; my $URLbase='http://Felist.Com/stat'; my $StatFile='d.text'; # # MAIN # if (@ARGV != 1) { print STDERR "Usage: robostat.pl list.id\n"; exit(1); } my ($id) = @ARGV; my $url = $URLbase.'/'.$id.'/'.$StatFile; my $ua = new LWP::UserAgent; $ua->agent('RoboStat/1.0'); # hee :-) my $req = new HTTP::Request GET => $url; $req->header('Accept' => 'text/html, text/plain'); my $result = $ua->request($req); if (! $result->is_success) { print STDERR 'robostat: FATAL: '.$result->code.' for '.$url."\n"; exit(2); } my @stat = split(' ',$result->content); chomp(@stat); if ($stat[0] ne '1.00') { print STDERR 'robostat: FATAL: unsupported format\'s version '.$stat[0]."\n"; exit(3); } ### to do something. change for needed print STDOUT "Statistics version $stat[0] Subscribers' number $stat[1] Change $stat[2] "; ### exit(0);