]> git.ipfire.org Git - thirdparty/cups.git/blob - test/waitjobs.sh
Import CUPS v1.7.1
[thirdparty/cups.git] / test / waitjobs.sh
1 #!/bin/sh
2 #
3 # "$Id: waitjobs.sh 1253 2009-02-25 23:37:25Z msweet $"
4 #
5 # Script to wait for jobs to complete.
6 #
7 # Copyright 2008-2009 by Apple Inc.
8 #
9 # These coded instructions, statements, and computer programs are the
10 # property of Apple Inc. and are protected by Federal copyright
11 # law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 # which should have been included with this file. If this file is
13 # file is missing or damaged, see the license at "http://www.cups.org/".
14 #
15
16 #
17 # Get timeout from command-line
18 #
19
20 if test $# = 1; then
21 timeout=$1
22 else
23 timeout=360
24 fi
25
26 #
27 # Figure out the proper echo options...
28 #
29
30 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
31 ac_n=-n
32 ac_c=
33 else
34 ac_n=
35 ac_c='\c'
36 fi
37
38 echo $ac_n "Waiting for jobs to complete...$ac_c"
39 oldjobs=0
40
41 while test $timeout -gt 0; do
42 jobs=`../systemv/lpstat 2>/dev/null | wc -l | tr -d ' '`
43 if test $jobs = 0; then
44 break
45 fi
46
47 if test $jobs != $oldjobs; then
48 echo $ac_n "$jobs...$ac_c"
49 oldjobs=$jobs
50 fi
51
52 sleep 5
53 timeout=`expr $timeout - 5`
54 done
55
56 echo ""
57
58 #
59 # End of "$Id: waitjobs.sh 1253 2009-02-25 23:37:25Z msweet $".
60 #