-
Notifications
You must be signed in to change notification settings - Fork 7
/
qctrl.sh
executable file
·83 lines (73 loc) · 2.02 KB
/
qctrl.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
GOODLIST=goodfiles.txt
#mkdir -p done
plotext='.ps.gz'
dispprog='gv -geometry +0+0'
eval set -- $(getopt -s bash 'e:D:h' "$@")
while true; do
case "$1" in
-e ) plotext="$2"
shift; shift ;;
-D ) dispprog="$2"
shift; shift ;;
-h ) help=1
shift;;
-- ) shift
break;;
esac
done
if [[ ${help} || ($# -lt 2) ]]; then
echo "" 1>&2
echo "Perform quality control on archive files."
echo "" 1>&2
echo "USAGE: $0 [OPTIONS] -- FILE [FILE ...]" 1>2&
echo "" 1>&2
echo "-e <plot ext> Extension to be added to archive file names to " 1>&2
echo " get the diagnostic plot filenames that should " 1>&2
echo " be displayed." 1>&2
echo " (Default: '.ps.gz')" 1>&2
echo "-D Program to use to display diagnostic plots. " 1>&2
echo " (Default: gv -geometry +0+0)" 1>&2
echo "-h Display this help" 1>&2
echo "" 1>&2
exit 1
fi
for fn in $* ; do
imgfn="${fn}${plotext}"
# Check if this file has already passed
if grep -Fq ${fn} ${GOODLIST} &>/dev/null; then
echo "${fn} already marked as good"
continue
fi
echo "Checking ${fn}"
echo "${dispprog} ${imgfn}"
# Display the plot
echo "Displaying ${imgfn}"
${dispprog} ${imgfn} &>/dev/null &
pid=$!
# Get receiver code and interpret it
read -N 1 -s -p "Good? Y/N> " GOOD
case $GOOD in
"y")
echo "${fn} is good"
# mv ${fn}* done/
readlink -f ${fn} >> ${GOODLIST}
;;
"Y")
echo "${fn} is good"
# mv ${fn}* done/
readlink -f ${fn} >> ${GOODLIST}
;;
"n")
echo "${fn} still needs work"
;;
"N")
echo "${fn} still needs work"
;;
*)
echo "Unrecognized selection ${GOOD}." 1>&2
esac
# Clean up and prepare for next interation of loop
kill $pid &> /dev/null
shift
done