]>
Commit | Line | Data |
---|---|---|
839a51c8 MS |
1 | #!/bin/sh |
2 | # | |
839a51c8 MS |
3 | # Script to wait for jobs to complete. |
4 | # | |
b9faaae1 | 5 | # Copyright 2008-2009 by Apple Inc. |
839a51c8 MS |
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 | ||
b9faaae1 | 14 | # |
839a51c8 | 15 | # Get timeout from command-line |
b9faaae1 MS |
16 | # |
17 | ||
839a51c8 MS |
18 | if test $# = 1; then |
19 | timeout=$1 | |
20 | else | |
b9faaae1 MS |
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' | |
839a51c8 MS |
34 | fi |
35 | ||
b9faaae1 MS |
36 | echo $ac_n "Waiting for jobs to complete...$ac_c" |
37 | oldjobs=0 | |
839a51c8 MS |
38 | |
39 | while test $timeout -gt 0; do | |
b9faaae1 MS |
40 | jobs=`../systemv/lpstat 2>/dev/null | wc -l | tr -d ' '` |
41 | if test $jobs = 0; then | |
839a51c8 MS |
42 | break |
43 | fi | |
44 | ||
b9faaae1 MS |
45 | if test $jobs != $oldjobs; then |
46 | echo $ac_n "$jobs...$ac_c" | |
47 | oldjobs=$jobs | |
48 | fi | |
49 | ||
839a51c8 MS |
50 | sleep 5 |
51 | timeout=`expr $timeout - 5` | |
52 | done | |
53 | ||
b9faaae1 | 54 | echo "" |