-
Notifications
You must be signed in to change notification settings - Fork 3
/
print-glabel-with-serial.sh
executable file
·57 lines (44 loc) · 1.4 KB
/
print-glabel-with-serial.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#! /bin/bash
# Requires glabels
# LPR printer
# Either run with default options > `./lablel
# Or specify template & printer ./label <template.glables> <LPR printer>
# Number of random codes to generate
QTY=12
# Number of characters per raandom coe
CHARACTERS=9
# filename to save codes
SERIAL="serial.csv"
# Filename to save generated labels
GENERATED="output.pdf"
# Default glables template
TEMPLATE="emonevse-dataplate.glabels"
# Default Printer
PRINTER="pi-Kyocera_FS-C5150DN"
OPTIONS="-o KCEcoprint=Off -o MediaType=Transparency"
#OPTIONS="-o KCEcoprint=Off"
##############################################################
echo -e "\nOpenEnegyMonitor label generator V1.0\n"
> serial.csv
echo -e "Generating random strings...\n"
for (( i=1; i<=$QTY; i++))
do
STR=$(tr -dc a-f0-9 < /dev/urandom | dd bs=$CHARACTERS count=1 2> /dev/null)
echo $STR >> $SERIAL
done
cat $SERIAL
if [ "$1" != "" ]; then
echo -e "\nGenerating labels using $1.glabels template...\n"
glabels-3-batch --input=$SERIAL $1
else
echo -e "\nGenerating labels using $TEMPLATE template...\n"
glabels-3-batch --input=$SERIAL $TEMPLATE
fi
echo
if [ "$2" != "" ]; then
read -p "$GENERATED generated press Enter to print on $2 or [CTRL+C] to exit"
lpr -P $2
else
read -p "$GENERATED generated press Enter to print on $PRINTER with options $OPTIONS or [CTRL+C] to exit"
lpr -P $PRINTER $GENERATED $OPTIONS
fi