Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
srohatgi01
GitHub Repository: srohatgi01/cups
Path: blob/master/test/waitjobs.sh
1090 views
1
#!/bin/sh
2
#
3
# Script to wait for jobs to complete.
4
#
5
# Copyright © 2008-2019 by Apple Inc.
6
#
7
# Licensed under Apache License v2.0. See the file "LICENSE" for more
8
# information.
9
#
10
11
#
12
# Get timeout from command-line
13
#
14
15
if test $# = 1; then
16
timeout=$1
17
else
18
timeout=360
19
fi
20
21
#
22
# Figure out the proper echo options...
23
#
24
25
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
26
ac_n=-n
27
ac_c=
28
else
29
ac_n=
30
ac_c='\c'
31
fi
32
33
#
34
# Check whether we have any jobs to wait for...
35
#
36
37
jobs=`$runcups ../systemv/lpstat 2>/dev/null | wc -l | tr -d ' '`
38
if test $jobs = 0; then
39
exit 0
40
fi
41
42
#
43
# We do, let the tester know what is going on...
44
#
45
46
echo $ac_n "Waiting for jobs to complete...$ac_c"
47
oldjobs=0
48
49
while test $timeout -gt 0; do
50
jobs=`$runcups ../systemv/lpstat 2>/dev/null | wc -l | tr -d ' '`
51
if test $jobs = 0; then
52
break
53
fi
54
55
if test $jobs != $oldjobs; then
56
echo $ac_n "$jobs...$ac_c"
57
oldjobs=$jobs
58
fi
59
60
sleep 5
61
timeout=`expr $timeout - 5`
62
done
63
64
echo ""
65
66