# coded by : Justin Lee # desc : just a quick hack for copying ArcView 3.2 extensions # license : under GNU GPL v2, you know the drill # date : February 10, 2008 use strict; use FileHandle; use File::Copy qw(copy); # use L:\ for ease of copy system('net use L: /DELETE'); print "\n" x 20; sleep 1; system('net use L: "\\\\Lyca\\Warehouse\\04_Software\\Applications\\ESRI\\Extensions\\AVX_Files"'); print "\n" x 20; print "Network folder mounted.\n"; # enter extensions dir chdir('C:/ESRI/AV_GIS30/ARCVIEW/EXT32') or die; print "Local extensions folder entered.\n" # open local (LOC) and remote (REM) directories for reading opendir(REM,'L:/') or die "WARNING: UNABLE TO OPEN REM (FATAL)\n"; opendir(LOC,'./') or die "WARNING: UNABLE TO OPEN LOC (FATAL)\n"; print "Local and remote directories opened for reading.\n"; my %path = ( # get the remote files 'REM' => [ readdir(REM) ], # get the local files (prep'd for checking) 'LOC' => { map { $_ => 1 } readdir(LOC) } ); # close the directories closedir(REM) or warn "WARNING: REM NOT CLOSED (NON-FATAL)\n"; closedir(LOC) or warn "WARNING: LOC NOT CLOSED (NON-FATAL)\n"; print "Directories read!\n"; # core "test and copy" function foreach my $rem (@{$path{'REM'}}) { # we only want extensions and libraries next unless $rem =~ /\.(?:avx|dll|dat|hdr)$/oi; # do we already have that extension? next if $path{'LOC'}->{$rem}; # get ready to copy the file by opening it my $from = new FileHandle "L:/$rem", '<'; # check to make sure it worked, else report and skip it do { print "We had a problem opening `L:\\$rem'!\n"; undef $from; next; } unless defined $from; # time to copy, if it fails, report and skip it unless(copy($from,$rem)) { print "We had a problem copying `L:\\$rem'.\n"; } else { print "`L:\\$rem' successfully copied!\n"; } # close the remote file undef $from; } # ... ^_^ my $redo = 0; CHDIR: { # hahaha, I'm priceless unless(chdir('C:/')) { unless(chdir('D:/')) { unless(chdir($ENV{TEMP})) { unless(chdir($ENV{WINDIR})) { unless(chdir($ENV{HOMEDRIVE})) { unless($redo++) { print "well doesn't this suck!!\n", "good thing it really isn't", "important!\nbut I guess we", "can try once more for fun."; redo; } } } } } } } # wait someone to read the logs print "Press Enter To Continue...."; ; print "Remounting network drives.\n"; # have a nap sleep 1; # rebuild network map system('netmount.pl -Ppm'); # bye bye! exit 0;