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