reptizarx3 has asked for the wisdom of the Perl Monks concerning the following question:
Hi guys! First of all newbie here, but want to learn, need help about one script sfv checker for crc checking on uploaded files on ftp server(wingftp): My steps: 1.Download and install Stawberry perl x64 run on win7x64, (installed into C:\Strawberry) 2.Restart 3.Download String-CRC32-1.5.tar.gz and unzip it to other partition d: Installation instruc says: "perl Makefile.PL" "make" "make test" "make install" 4.Open Perl cmd and input D:\String-CRC32-1.5\Makefile.PL 5.input make and get this error: 'make' is not recognized as an internal or external command, operable program or batch file. What i doing wrong? Here is the whole script and don't know even i get to work:
#!/usr/bin/perl # Make sure this points to your perl executable # String::CRC32 is required you can install using cpan use String::CRC32; # Wing Server SFV Checker v1.00b - benny / clarjl3@students.fscj.edu # # I put this together because the sfv checker that comes with Wing Ser +ver isn't recursive # and wont check sub directories inside the specified sfv checking dir +ectory # # Apologies for the sloppy code I wanted a working sfv checker quick, +ill try and clean it # up and add more features when I have more time. # # Known bugs / Irrelevant issues? # - As of now this will only check files in a sfv against the files u +ploaded # to the directory that your uploading to, so if any file not in th +e sfv is uploaded # it will just be ignored and possible to just have misc unwanted f +iles laying around.. # # - The $home variable could cause issues with multiple domains and u +sers depending on your setup.. # on my setup i have all my files going to /usr/files and my one us +er having a home directory of /usr/files # so everything sent to this script would be /Dircreated/Files.. wh +ich would be # ($home/Dircreated/Files) -> /usr/files/Dircreated/Files # - I'll add a more flexable $home in the future! # # - If there is more than one sfv this script will just exit.. # # Using / Installing this # - You will need to run cpan and install String::CRC32 # - Put this perl script somewhere you can find it later # - chmod +x /path/to/where/you/put/checker # # - Goto the Wing Server http admin panel and click on a domain # - Click on Ftp Events # - Double Click OnFileUploaded # - Check mark "Enable Execute Program" # - Program Path is /path/to/where/you/put/checker you did earlie +r # - For Paramaters put: %Dir # - Press OK! # # Conclusion # - I would recommend having your ftp client set a priority on sendin +g sfv first but on a side # note even if you sent a few files first and then uploaded the sfv + how this scans files apon upload # it will check the previous files you uploaded and add them to the + cached files # # - Enjoy and let me know if you have troubles or like this! # my $home = "/usr/files"; my $sfiles = 0; my $tfiles = 0; # For creating empty missing/bad files sub touch { if ($#_ != 0) { return; } if ( -f $_[0] ) { return; } open tch, ">$_[0]"; close tch; } opendir(SFVCHK, ${home}.$ARGV[0]); my @SFVFIN = grep(/\.sfv/, readdir( +SFVCHK)); closedir(SFVCHK); opendir(SFVCHK, ${home}.$ARGV[0]); my @CMPCHK = grep(/^\[.*COMPLETE\s\ +]$/, readdir(SFVCHK)); closedir(SFVCHK); # If there isn't a sfv or more than 1 just exit if (@SFVFIN != 1) { exit; } # Keep a hidden verified file to prevent double checking and system lo +ad my @CHECKED = (); if ( -e "${home}$ARGV[0]/.chk" ) { open CKSFV, "<${home}$ARGV[0]/.chk"; while (<CKSFV>) { chomp($_); push(@CHECKED, $_); } close CKSFV; } # Open file for appending anymore valid files we might come across open CKSFV, ">>${home}$ARGV[0]/.chk"; # Open the sfv and log the files that are suppose to be here # before we run the sfv checker to compare open SFVFD, "<${home}$ARGV[0]/$SFVFIN[0]"; while (<SFVFD>) { chomp($_ +); push(@LINES, $_); } close SFVFD; foreach my $deldir (@CMPCHK) { rmdir "${home}$ARGV[0]/$deldir"; } foreach my $line (@LINES) { chomp($line); if ($line =~ /^;/) { next; } my @SP = split(/ /, $line); my $rel = uc($SP[1]); $tfiles++; $rel =~ s/(\W)//g; # Make sure the crc string doesnt contain a +ny control characters if ( -e "${home}$ARGV[0]/$SP[0]" ) { my $LFILE = $SP[0]; if (grep(/$LFILE/, @CHECKED)) { $sfiles++; next; } open(CRCK, "${home}$ARGV[0]/$SP[0]"); my $crc = crc32(*CRCK) +; close(CRCK); my $hex = sprintf "%x", $crc; $hex = uc($hex); if (length($hex) < 8) { $hex = "0".$hex; } if (length($rel) < 8) { $rel = "0".$rel; } if ($hex eq $rel) { if ( -e "${home}$ARGV[0]/$SP[0]-missing" ) { unlink("$ +{home}$ARGV[0]/$SP[0]-missing"); } if ( -e "${home}$ARGV[0]/$SP[0]-bad" ) { unlink("${hom +e}$ARGV[0]/$SP[0]-bad"); } print CKSFV "$LFILE\n"; $sfiles++; } else { if ( ! -e "${home}$ARGV[0]/$SP[0]-bad" ) { touch("${ho +me}$ARGV[0]/$SP[0]-bad"); } } } else { if ( -e "${home}$ARGV[0]/$SP[0]-missing" ) { next; } touch("${home}$ARGV[0]/$SP[0]-missing"); } } close CKSFV; my $newdir = sprintf "[ %iF %iF FILES - 0.00%% COMPLETE ]", $sfiles, $ +tfiles; if ($sfiles != 0) { $newdir = sprintf "[ %iF of %iF - %.1f%% COMPLETE +]", $sfiles, $tfiles, (($sfiles / $tfiles) * 100); } if ($sfiles == $tfiles) { $newdir = "[ ${tfiles}F COMPLETE ]"; } mkdir "${home}$ARGV[0]/$newdir";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: sfv checker sting crc32
by Corion (Patriarch) on Oct 20, 2016 at 17:13 UTC | |
by reptizarx3 (Novice) on Oct 20, 2016 at 19:02 UTC | |
by Corion (Patriarch) on Oct 20, 2016 at 19:05 UTC | |
by reptizarx3 (Novice) on Oct 21, 2016 at 07:02 UTC | |
by soonix (Chancellor) on Oct 21, 2016 at 07:16 UTC | |
by Corion (Patriarch) on Oct 21, 2016 at 07:12 UTC | |
|
Re: sfv checker sting crc32
by reptizarx3 (Novice) on Oct 21, 2016 at 07:21 UTC | |
by soonix (Chancellor) on Oct 21, 2016 at 07:31 UTC | |
by reptizarx3 (Novice) on Oct 21, 2016 at 07:53 UTC | |
by soonix (Chancellor) on Oct 21, 2016 at 07:59 UTC | |
by reptizarx3 (Novice) on Oct 21, 2016 at 08:26 UTC | |
| |
by reptizarx3 (Novice) on Oct 22, 2016 at 10:04 UTC |