Created
August 16, 2016 13:44
-
-
Save brinxmat/c6309c76efd37cf72af27f6239f9c740 to your computer and use it in GitHub Desktop.
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
#! /usr/bin/env bash | |
#debugging on | |
set -x | |
# Output "device discovery" information on stdout: | |
if test "$#" = "0" | |
then echo 'network barcoder "Unknown" "barcoder"' | |
exit 0 | |
fi | |
SINGLE=$(egrep -o "\bStrekkode [0-9]{14}\b" "$6") | |
if [[ ! -z $SINGLE ]] | |
then | |
DATA="${SINGLE//Strekkode /}" | |
else | |
DATA=$(egrep -o "\b[0-9]{14}\b" "$6") | |
fi | |
while read -r line ; do | |
JSON=$(curl -L "http://koha1.deichman.no:8081/api/v1/labelgenerator/$line") | |
FILENAME="$TMPDIR$line.pdf" | |
if [ "$JSON" != '{"error":"No items found"}' ] | |
then | |
java -jar labelpdf-all-1.0-SNAPSHOT.jar \ | |
--data="$JSON"\ | |
--output="$FILENAME" \ | |
&& lpr -P DYMO_LabelWriter_450___raspberrypi -o media=Custom.36x89mm "$FILENAME" \ | |
&& rm "$FILENAME" | |
fi | |
done <<< "$DATA" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment