summaryrefslogtreecommitdiff
path: root/test/waitjobs.sh
blob: 01c581db5dbf1acc57a32d05e534392e7f437511 (plain)
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
#!/bin/sh
#
# "$Id: waitjobs.sh 1253 2009-02-25 23:37:25Z msweet $"
#
# Script to wait for jobs to complete.
#
#   Copyright 2008-2009 by Apple Inc.
#
#   These coded instructions, statements, and computer programs are the
#   property of Apple Inc. and are protected by Federal copyright
#   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
#   which should have been included with this file.  If this file is
#   file is missing or damaged, see the license at "http://www.cups.org/".
#

#
# Get timeout from command-line
#

if test $# = 1; then
	timeout=$1
else
	timeout=360
fi

#
# Figure out the proper echo options...
#

if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
        ac_n=-n
        ac_c=
else
        ac_n=
        ac_c='\c'
fi

echo $ac_n "Waiting for jobs to complete...$ac_c"
oldjobs=0

while test $timeout -gt 0; do
	jobs=`../systemv/lpstat 2>/dev/null | wc -l | tr -d ' '`
	if test $jobs = 0; then
		break
	fi

	if test $jobs != $oldjobs; then
		echo $ac_n "$jobs...$ac_c"
		oldjobs=$jobs
	fi

	sleep 5
	timeout=`expr $timeout - 5`
done

echo ""

#
# End of "$Id: waitjobs.sh 1253 2009-02-25 23:37:25Z msweet $".
#