Thread: [X2serv-cvs] CVS: x2/tools find_defunct_chans.pl,1.1,1.2
Brought to you by:
sirvulcan
From: John M. <jmc...@us...> - 2001-05-31 17:42:27
|
Update of /cvsroot/x2serv/x2/tools In directory usw-pr-cvs1:/tmp/cvs-serv8139/tools Modified Files: find_defunct_chans.pl Log Message: Added david's email address to the comments per his request. Index: find_defunct_chans.pl =================================================================== RCS file: /cvsroot/x2serv/x2/tools/find_defunct_chans.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** find_defunct_chans.pl 2001/05/31 01:41:48 1.1 --- find_defunct_chans.pl 2001/05/31 17:42:00 1.2 *************** *** 1,107 **** ! #!/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 ----- --- 1,108 ---- ! #!/usr/bin/perl ! ! # ---------- ! # find_defunct_chans.pl ! # 5-30-01 ! # David "FUna" Holstein ! # dv...@68... ! # ---------- ! # ! # 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 ----- |