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

    For Strawberry Perl, the tool is named dmake, not make. But with Perl, the easier way for installing modules is to simply run the cpan command:

    cpan String::CRC32

      Thanks! But prefer without cpan. Open Perl command line: 1. Makefile.PL Generating a dmake-style Makefile Writing Makefile for String::CRC32 Writing MYMETA.yml and MYMETA.json and tried with dmake give me an error "damke error : 'Makefile.PL' not found and can't be made Where i must extract the content of String-CRC32-1.5?

        Please first try to get things working the easy way before trying the hard way.

        Your error message makes no sense. The normal command sequence for a manual installation on Windows with dmake is:

        perl Makefile.PL dmake dmake test dmake install

        At no time, dmake should try to remake Makefile.PL, so please copy the exact error message instead of copying some vague interpretation of it. Also, please consider using <code>...</code> tags around the code and data you are pasting so your posts show up in a more readable way.

Re: sfv checker sting crc32
by reptizarx3 (Novice) on Oct 21, 2016 at 07:21 UTC

    Thank you! If i use cpan i must download String-CRC32-1.5.tar.gz unrar/unzip into C:\Strawberry\perl\bin. My question is every module need to be into this directory or C:\widows dir or its not necessary?

      cpan can download and unzip the modules on its own.

      Strawberry's cpan command is configured to install them into a "lib" folder, which is already in perl's search path.

        Thank you! Its not a problem now that String-CRC32-1.5 folder is into bin folder right? And now the hard part of sfv script: Instructions says: "Put this perl script somewhere you can find it later and then i must execute this cmd "

         chmod +x /path/to/where/you/put/checker

        What i must do next exactly? The sfv script in upper of the page i must copy the .txt file somewhere?

        Any new suggestion how to proceed?