Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fileCheck() {
- perl -e '
- use Digest::MD5 qw(md5);
- $file = shift; die "no file [$file]" unless -f $file;
- $compFile = shift; $compFile = 0 unless -f $compFile;
- $sleep = 1;
- sleep $sleep;
- if($compFile ne 0){
- $format = "%0.2fM \t %0.2fM \t %.2f%%\n";
- }else{
- $format = "%0.2f %0.2f\n";
- }
- $counter = 1;
- while(1){
- $size = ((stat($file))[7]);
- if($lastsize != $size){
- $counter = 1;
- }else{
- $counter--;
- if($counter <= 0){
- print "\n\nCopy/loading/whatever finished\n";
- if($compFile ne 0){
- print "starting checksum...\n";
- open FILE, $file;
- binmode FILE;
- $data = <FILE>;
- close FILE;
- $chkFile = md5($data);
- open FILE, $compFile;
- binmode FILE;
- $data = <FILE>;
- close FILE;
- $chkComp = md5($data);
- print "\n$chkFile\n$chkComp\n";
- if($chkFile eq $chkComp){
- print "seems legit\n";
- }else{
- print "something might be wrong\n";
- }
- }
- my $hash;
- {
- local $/ = undef;
- open FILE, "$wav_file_name";
- binmode FILE;
- my $data = <FILE>;
- close FILE;
- $hash = md5($data);
- }
- exit;
- }
- next;
- }
- $change = $size - $lastsize;
- if($compFile ne 0){
- $compSize = ((stat($compFile))[7]);
- $compPerc = $size / ( $compSize / 100);
- }
- printf $format, $size/1024/1024, $change/1024/1024/$sleep, ($compFile ne 0 ? $compPerc : null);
- sleep $sleep;
- $lastsize = $size;
- }' "$1" "$2"
- }
- mcp(){
- if [ ! -f $1 ]; then
- echo "File $1 not found!"
- exit
- else
- src=$1
- fi
- if [ -d $2 ]; then
- dst="$2$(basename $1)"
- else
- dst=$2
- fi
- cp $src $dst &
- fileCheck $dst $src
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement