#!/usr/local/bin/perl use TCPIP; use Socket; use Getopt::Std; getopts ('h:u:p:', \%opts); $hostname = $opts{'h'} || 'ginger.media.kyoto-u.ac.jp'; $username = $opts{'u'}; $password = $opts{'p'}; exit (0) if (@ARGV == 0); tcp_client(S, $hostname, 119); select(S); $|=1; select(STDIN); $|=1; select(STDOUT); $|=1; if ( =~ /^[^2]/) { printf STDERR "Permission Denied.\n"; exit (1); } modereader (); if (!($username eq "") && !($password eq "")) { authinfo ($username, $password); } foreach $newsgroup (@ARGV) { xover ($newsgroup); } exit (0); sub modereader () { printf S "mode reader\r\n"; $_ = ; if (/^[^2]/) { printf STDERR "Permission Denied.:%s\n", $_; exit (1); } } sub authinfo ($$) { printf S "authinfo user %s\r\n", $_[0]; $_ = ; if (/^[^3]/) { chomp; printf STDERR "%s\n", $_; exit (1); } printf S "authinfo pass %s\r\n", $_[1]; $_ = ; if (/^[^2]/) { chomp; printf STDERR "%s\n", $_; exit (1); } } sub xover ($) { printf S "group %s\r\n", $_[0]; $_ = ; if ($_ !~ /^2\d\d \d+ (\d+) (\d+)/) { # cannot groupnn chomp; printf STDERR "%s\n", $_; return; } printf S "xover %d-%d\r\n", $1, $2; $_ = ; if ($_ !~ /^2\d\d/) { # cannot xover chomp; printf STDERR "%s\n", $_; return; } while ($_ = ) { last if ($_ eq ".\r\n"); split ("\t", $_); printf "%s\n", $_[4]; } }