#! /usr/bin/perl -w # lynx -dump -width=1000 http://freshrpms.net/misc/enigma.html > enigma.txt use strict; our $in_usa = 0; our @wget; our @ncftpget; use constant NCFTPGET => '/usr/bin/ncftpget'; use constant ENIGMA_SITES => "/root/enigma.txt"; use constant RH72_DIR => "/var/ftp/pub/redhat-7.2"; use constant MUST_BE_ROOT => 1; die "must be run as root\n" if MUST_BE_ROOT and $< != 0; unless ( -f ENIGMA_SITES ) { system 'lynx -dump -width=1000 http://freshrpms.net/misc/enigma.html > ' . ENIGMA_SITES; } chdir RH72_DIR or die "Cannot change to " . RH72_DIR . ": $!"; while ( 1 ) { open ENIGMA, "< " . ENIGMA_SITES or warn "Cannot open " . ENIGMA_SITES . ": $!"; while ( ) { $in_usa = 1 if /North America/; $in_usa = 0 if /South America/; next unless $in_usa; chomp; our ( $url, $scheme, $host, $path ) = m#(((?:ftp|http))://([^/]+)(/\S+/7.2))#; next unless $url; $url .= "/"; if ( $scheme eq 'http' ) { @wget = ( '/usr/bin/wget', '-nH', '-l0', '-c', '--no-parent', '-m', $url ); #print "@wget\n"; next; system( @wget ) == 0 or warn "error with @wget: $!"; } elsif ( $scheme eq 'ftp' ) { @ncftpget = ( NCFTPGET, '-R', $url ); system( @ncftpget ) == 0 or warn "error with @ncftpget: $!"; } else { warn "Unknown scheme '$scheme'\n"; } } close ENIGMA; }