Skip to content

Commit

Permalink
barcodeinterpret: add cleanup/trap and log functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Database committed Apr 8, 2013
1 parent b569087 commit 06a81ef
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions barcodeinterpret
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
#!/bin/bash
# interpret Interleaved 2/5 barcode 58 byte barcode values used by the ProBell tape management system

scriptdir=`dirname "$0"`
. "$scriptdir/mmvariables"
. "$scriptdir/mmfunctions"
[ ! -f "$scriptdir/mmvariables" -o ! -f "$scriptdir/mmfunctions" ] && { echo "Missing '$scriptdir/mmvariables' and/or '$scriptdir/mmfunctions'. Exiting." ; exit 1 ;};

cleanup(){
log -a "Process aborted"
exit 1
}

trap cleanup SIGHUP SIGINT SIGTERM
log -b

if test $# != 1
then
echo "You must supply one argument, a scanned interleaved 2/5 barcode value"; exit
Expand Down Expand Up @@ -55,3 +68,4 @@ 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)`
log -e

0 comments on commit 06a81ef

Please sign in to comment.