Metainformationen zur Seite

MD5-Hash - dirtree_md5.pl

The LoxBerry script dirtree_md5.pl creates md5 hashes of single files or of a full directory tree. It also can compare the md5 with a given md5 string.

Calling

$LBSBIN/dirtree_md5.pl <parameters>

(usually /opt/loxberry/bin/dirtree_md5.pl)

Parameters

Parameter Usage
-path <dirpath> Checks the complete directory tree. A tree is only "equal" if all files have the same md5, and also the number of files is equal (no more or less files) 
-file <filepath>Checks a single file
-compare <md5> Compares the result of -file/-path with the given md5. Returns 0 if equal, or 1 if NOT equal.
-v / -verbose Activate verbosity. Gives lists of files and md5's

Abstract

// Location of the script
$LBSBIN/dirtree_md5.pl
 
##########################
# Check directory tree   #
##########################
 
dirtree_md5.pl -path /tmp/
# Output:
2923ac2020c35d66812eb106d6b7bb09
 
dirtree_md5.pl -path /tmp/ -compare 2923ac2020c35d66812eb106d6b7bb09
# Output:
2923ac2020c35d66812eb106d6b7bb09
EQUAL: Checked 2923ac2020c35d66812eb106d6b7bb09 is equal to 2923ac2020c35d66812eb106d6b7bb09
# Exitcode: 0
 
dirtree_md5.pl -path /tmp/ -compare wrongmd5
# Output:
2923ac2020c35d66812eb106d6b7bb09
INVALID: Checked 2923ac2020c35d66812eb106d6b7bb09 is NOT equal to wrongmd5
# Exitcode: 1
 
#######################
# Check single files  #
#######################
 
dirtree_md5.pl -file /opt/loxberry/config/system/general.json
# Output:
# 39ca9bbef21cf96a1caff1d4dd363bf3
 
dirtree_md5.pl -file /opt/loxberry/config/system/general.json -compare 39ca9bbef21cf96a1caff1d4dd363bf3
# Output:
39ca9bbef21cf96a1caff1d4dd363bf3
EQUAL: Checked 39ca9bbef21cf96a1caff1d4dd363bf3 is equal to 39ca9bbef21cf96a1caff1d4dd363bf3
# Exitcode: 0
 
dirtree_md5.pl -file /opt/loxberry/config/system/general.json -compare wrongmd5
# Output:
39ca9bbef21cf96a1caff1d4dd363bf3
INVALID: Checked 39ca9bbef21cf96a1caff1d4dd363bf3 is NOT equal to wrongmd5
# Exitcode: 1
 
dirtree_md5.pl -file /does/not/exist.txt
# Output:
File /does/not/exist.txt not found
# Exitcode: 2