1#!/bin/sh 2# 3# "$Id: waitjobs.sh 1255 2009-02-25 23:56:31Z 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 20if test $# = 1; then 21 timeout=$1 22else 23 timeout=360 24fi 25 26# 27# Figure out the proper echo options... 28# 29 30if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then 31 ac_n=-n 32 ac_c= 33else 34 ac_n= 35 ac_c='\c' 36fi 37 38echo $ac_n "Waiting for jobs to complete...$ac_c" 39oldjobs=0 40 41while 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` 54done 55 56echo "" 57 58# 59# End of "$Id: waitjobs.sh 1255 2009-02-25 23:56:31Z msweet $". 60# 61