-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscancsv
More file actions
executable file
·77 lines (66 loc) · 1.54 KB
/
scancsv
File metadata and controls
executable file
·77 lines (66 loc) · 1.54 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
# Reads lines, prepends a timestamp and appends an optional delimiter
#
#
#
# Start a new file every serial number, so as soon as we encounter a serial number,
# store it, and use it as the output filename.
# Any scanned data is appended to that file
# q quits
# n next DUO
# t timestamp
VERSION="1.0.0-beta3"
while getopts "n:o:" option
do
case "${option}"
in
o) OUTDIR=${OPTARG};;
n) BUILDER=${OPTARG};;
esac
done
echo "Scancsv version $VERSION"
echo
# if outdir does not exist, exit with a message
if [[ ! -d "$OUTDIR" ]]; then
echo "Output directory specified with -o does not exist. Exiting."
exit 2
fi
cd "$OUTDIR"
echo "What is your name?"
read name
BUILDER="$name"
while :
do
echo "Name: $BUILDER"
echo "Enter serial number: press q to quit"
read SERIAL
case $SERIAL in
'q') exit 0;;
'8719326129501') echo "that is the DUO's barcode"; continue;;
*)
if [[ ! "$SERIAL" =~ ^(DUO|DRUM)?[0-9]+$ ]]; then
echo "not a valid serial number"
continue
fi
echo "Logging steps for serial no $SERIAL"
;;
esac
date "+%Y-%m-%d %H:%M:%S,$BUILDER" >> "$SERIAL".cs~
date "+%Y-%m-%d %H:%M:%S,start" >> "$SERIAL".cs~
while :
do
read
if [ "$REPLY" == "q" ]; then
exit 0
elif [ "$REPLY" == "n" ]; then
echo "$SERIAL is done!"
mv "$SERIAL".cs~ "$SERIAL".csv
echo
break
elif [ "$REPLY" == "t" ]; then
date "+%Y-%m-%d %H:%M:%S" >> "$SERIAL".cs~
else
date "+%Y-%m-%d %H:%M:%S,$REPLY" >> "$SERIAL".cs~
fi
done
done