-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standardized variables and functions across all mm scripts.
- Loading branch information
1 parent
9524798
commit ad37593
Showing
31 changed files
with
1,906 additions
and
1,904 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,68 @@ | ||
#!/bin/bash | ||
# interpret Interleaved 2/5 barcode 58 byte barcode values used by the ProBell tape management system | ||
|
||
scriptdir=$(dirname "${0}") | ||
. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; | ||
SCRIPTDIR=$(dirname "${0}") | ||
. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; | ||
|
||
cleanup(){ | ||
_cleanup(){ | ||
_log -a "Process aborted" | ||
exit 1 | ||
} | ||
|
||
trap cleanup SIGHUP SIGINT SIGTERM | ||
trap _cleanup SIGHUP SIGINT SIGTERM | ||
_log -b | ||
|
||
if test $# != 1 ; then | ||
if test "${#}" != 1 ; then | ||
echo "You must supply one argument, a scanned interleaved 2/5 barcode value"; exit | ||
fi | ||
|
||
barcode="${1}" | ||
BARCODE="${1}" | ||
|
||
translatebyte() | ||
{ | ||
val=$(echo $1 | echo $(cut -c $2-$3) + 32 | bc) | ||
if [ "$val" = 131 ] ; then | ||
echo 9 | awk '{printf("%c", $0);}' | ||
VAL=$(echo $1 | echo $(cut -c $2-$3) + 32 | bc) | ||
if [ "${VAL}" = 131 ] ; then | ||
echo 9 | awk '{printf("%c", ${0});}' | ||
else | ||
echo $val | awk '{printf("%c", $0);}' | ||
echo "${VAL}" | awk '{printf("%c", ${0});}' | ||
fi | ||
} | ||
addcolons() | ||
_addcolons() | ||
{ | ||
echo $(echo $1 | cut -c 1-2):$(echo $1 | cut -c 3-4):$(echo $1 | cut -c 5-6):$(echo $1 | cut -c 7-8) | ||
echo $(echo "${1}" | cut -c 1-2):$(echo "${1}" | cut -c 3-4):$(echo "${1}" | cut -c 5-6):$(echo "${1}" | cut -c 7-8) | ||
} | ||
|
||
get_ids() | ||
_get_ids() | ||
{ | ||
barcode=$1 | ||
c00=$(translatebyte $barcode 2 3) | ||
c01=$(translatebyte $barcode 4 5) | ||
c02=$(translatebyte $barcode 6 7) | ||
c03=$(translatebyte $barcode 8 9) | ||
c04=$(translatebyte $barcode 10 11) | ||
c05=$(translatebyte $barcode 12 13) | ||
c06=$(translatebyte $barcode 14 15) | ||
c07=$(translatebyte $barcode 16 17) | ||
c08=$(translatebyte $barcode 18 19) | ||
c09=$(translatebyte $barcode 20 21) | ||
c10=$(translatebyte $barcode 22 23) | ||
c11=$(translatebyte $barcode 24 25) | ||
c12=$(translatebyte $barcode 26 27) | ||
c13=$(translatebyte $barcode 28 29) | ||
c14=$(translatebyte $barcode 30 31) | ||
c15=$(translatebyte $barcode 32 33) | ||
c16=$(translatebyte $barcode 34 35) | ||
c17=$(translatebyte $barcode 36 37) | ||
c18=$(translatebyte $barcode 38 39) | ||
c19=$(translatebyte $barcode 40 41) | ||
echo $c00$c01$c02$c03$c04$c05$c06$c07$c08$c09$c10$c11$c12$c13$c14$c15$c16$c17$c18$c19 | ||
BARCODE=$1 | ||
c00=$(translatebyte "${BARCODE}" 2 3) | ||
c01=$(translatebyte "${BARCODE}" 4 5) | ||
c02=$(translatebyte "${BARCODE}" 6 7) | ||
c03=$(translatebyte "${BARCODE}" 8 9) | ||
c04=$(translatebyte "${BARCODE}" 10 11) | ||
c05=$(translatebyte "${BARCODE}" 12 13) | ||
c06=$(translatebyte "${BARCODE}" 14 15) | ||
c07=$(translatebyte "${BARCODE}" 16 17) | ||
c08=$(translatebyte "${BARCODE}" 18 19) | ||
c09=$(translatebyte "${BARCODE}" 20 21) | ||
c10=$(translatebyte "${BARCODE}" 22 23) | ||
c11=$(translatebyte "${BARCODE}" 24 25) | ||
c12=$(translatebyte "${BARCODE}" 26 27) | ||
c13=$(translatebyte "${BARCODE}" 28 29) | ||
c14=$(translatebyte "${BARCODE}" 30 31) | ||
c15=$(translatebyte "${BARCODE}" 32 33) | ||
c16=$(translatebyte "${BARCODE}" 34 35) | ||
c17=$(translatebyte "${BARCODE}" 36 37) | ||
c18=$(translatebyte "${BARCODE}" 38 39) | ||
c19=$(translatebyte "${BARCODE}" 40 41) | ||
echo "${c00$c01$c02$c03$c04$c05$c06$c07$c08$c09$c10$c11$c12$c13$c14$c15$c16$c17$c18$c19}" | ||
} | ||
|
||
ids=$(get_ids $barcode) | ||
IDS=$(_get_ids "${BARCODE}") | ||
|
||
materialid=$(echo $ids | cut -d ' ' -f 2) | ||
if [[ $(echo "$materialid" | tail -c +9 | head -c 1) == "H" ]] ; then | ||
materialid="${materialid}D" | ||
MATERIALID=$(echo "${IDS}" | cut -d ' ' -f 2) | ||
if [[ $(echo "${MATERIALID}" | tail -c +9 | head -c 1) == "H" ]] ; then | ||
MATERIALID="${MATERIALID}D" | ||
fi | ||
echo deviceid,$(echo $ids | cut -d ' ' -f 1),materialid,$materialid,som,$(addcolons $(echo $barcode | cut -c 42-49)),duration,$(addcolons $(echo $barcode | cut -c 50-57)) | ||
echo DEVICEID,$(echo "${IDS}" | cut -d ' ' -f 1),MATERIALID,${MATERIALID},SOM,$(_addcolons $(echo "${BARCODE}" | cut -c 42-49)),duration,$(_addcolons $(echo "${BARCODE}" | cut -c 50-57)) | ||
_log -e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,46 @@ | ||
#!/bin/bash | ||
# blackatends | ||
# Accepts one or many video files as an input and determines how many frames of black are at the beginning and at the end | ||
scriptdir=$(dirname "${0}") | ||
. "${scriptdir}/mmfunctions" || { echo "Missing '${scriptdir}/mmfunctions'. Exiting." ; exit 1 ;}; | ||
version=1.0 | ||
SCRIPTDIR=$(dirname "${0}") | ||
. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;}; | ||
VERSION=1.0 | ||
|
||
cleanup(){ | ||
_cleanup(){ | ||
_log -a "Process aborted" | ||
exit 1 | ||
} | ||
|
||
trap cleanup SIGHUP SIGINT SIGTERM | ||
trap _cleanup SIGHUP SIGINT SIGTERM | ||
|
||
usage(){ | ||
_usage(){ | ||
echo | ||
echo "$(basename "${0}") ${version}" | ||
echo "$(basename "${0}") ${VERSION}" | ||
echo "This program will report on the number of black frames at the beginning and end of a video file." | ||
echo | ||
echo "Usage: $(basename $0) file1 [ file2 ... ]" | ||
echo "Usage: $(basename ${0}) file1 [ file2 ... ]" | ||
echo | ||
echo "Options:" | ||
echo " -h display this help" | ||
echo | ||
exit | ||
} | ||
[ "$#" = 0 ] && usage | ||
[ "${#}" = 0 ] && _usage | ||
|
||
# command-line options to set mediaid and original variables | ||
OPTIND=1 | ||
while getopts ":h" opt; do | ||
case "$opt" in | ||
h) usage ;; | ||
\?) echo "Invalid option: -$OPTARG" ; exit 1 ;; | ||
:) echo "Option -$OPTARG requires an argument" ; exit 1 ;; | ||
while getopts ":h" OPT; do | ||
case "${OPT}" in | ||
h) _usage ;; | ||
\?) echo "Invalid option: -${OPTARG}" ; exit 1 ;; | ||
:) echo "Option -${OPTARG} requires an argument" ; exit 1 ;; | ||
esac | ||
done | ||
shift $(( ${OPTIND} - 1 )) | ||
|
||
while [ "${*}" != "" ] ; do | ||
_log -b | ||
[ "$#" != 0 ] && sourcefile="${1}" | ||
black_at_ends "$sourcefile" | ||
[ "${#}" != 0 ] && SOURCEFILE="${1}" | ||
_black_at_ends "${SOURCEFILE}" | ||
_log -e | ||
shift | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.