[X2serv-cvs] CVS: x2/tools find_defunct_chans.pl,NONE,1.1
Brought to you by:
sirvulcan
From: Alex S. <ru...@us...> - 2001-05-31 01:41:54
|
Update of /cvsroot/x2serv/x2/tools In directory usw-pr-cvs1:/tmp/cvs-serv2035 Added Files: find_defunct_chans.pl Log Message: Added a script funa wrote to find defunct data files in CHANS/ (those which are not in chan.dat) --- NEW FILE --- #!/usr/bin/perl # ---------- # x2_parse.pl # 5-30-01 # David "FUna" Holstein # ---------- # # A script to scan though CHANS/ and compare it to chan.dat, moving any # unregistered but existing data files to defunct_chans/ directory. # # Create a directory called defunct_chans in the base directory and make sure to # set the permissions. Then run this bitch and pray. # # NOTE: I believe this is ment to be run from the main x2 directory.. -Rubin # ---------- # Released under the General Public Liscense http://www.gnu.org # ---------- # # # Print a welcome message # print "\n\n"; print "--------------------------\n"; print "X2 Channel Database Parser\n"; print "--------------------------\n\n"; # Define some variables for later $true = 1; $false = 0; # # Load chan.dat # print "\n*** Loading chans.dat...\n\n"; open(CHANDAT, "chan.dat"); @chanList = <CHANDAT>; close(CHANDAT); # # Open a directory and load all filenames present # print "*** Loading names of all files in directory\n\n"; opendir(CHANS, "CHANS"); @chanFiles = readdir(CHANS); close(CHANS); # Debug - print chanfiles found. #for ($i = 0; $i < $#chanFiles; $i++) { # print "$chanFiles[$i]\n"; #} # # Search for files that are not in chan.dat # If not found, move them to another folder # for ($i = 0; $i <= $#chanFiles; $i++) { # Convert channel name to uppercase and add a # $channelFile = "#" . uc($chanFiles[$i]); # Set the found flag to false by default $found = $false; for ($z = 0; $z <= $#chanList; $z++) { # Convert channel name from chanList to uppercase. $channel = uc($chanList[$z]); # Remove the newline character from the end of the string. chop($channel); if ($channel eq $channelFile) { # If the channel is found, set found flag to true. $found = $true; # Print message stating it was found. print "$chanFiles[$i] found in database...skipping.\n"; } } # # If Channel not found, move it. # if ($found == $false) { # Read the file into memory open(MOVEFILE, "CHANS/$chanFiles[$i]"); @moveFile = <MOVEFILE>; close(MOVEFILE); # Write to destination open(MOVEDEST, ">defunct_chans/$chanFiles[$i]"); for ($y = 0; $y <= $#moveFile; $y++) { print MOVEDEST "$moveFile[$i]"; } close(MOVEDEST); # Delete the old file unlink("CHANS/$chanFiles[$i]"); # Print message. print "$chanFiles[$i] not found, moving to defunct_chans/$chanFiles[$i]\n"; } } # Let the user know its all over print "\n\n*** FINISHED!!!!\n\n"; # ----- END ----- |