Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
for prt in `lsallq`
do
stat=`lpstat -p$prt`
echo "$stat" | grep -i down > /dev/null 2>1 && echo "$stat"
done
#!/usr/local/bin/expect
# remove the leftmost element of a list and return it
# this function should really be a part tcl
proc pop {lname} {
upvar $lname lst
set tmp [lindex $lst 0]
set lst [lreplace $lst 0 0]
return $tmp
}
# don't show the user the ugly workings
log_user 0
# build a list containing all queue names
set printers {}
spawn lsallq
while {1} {
expect {
-re "(\[^\r]*)\r\n" {lappend printers $expect_out(1,string)}
eof {
wait
break
}
}
}
set printers [lsort $printers]
# launch up to 30 lpstat processes in parallel.
# Many more, and you start hitting the per user
# process limit (lpstat spawns several processes of
# its own).
set lpstatids {}
for {set count 0} {$count < 30} { incr count} {
spawn lpstat -p[pop printers]
lappend lpstatids $spawn_id
}
# run through the spawned processes, showing their
# output. As each dies, spawn one of the remaining
# printers, if any.
while { [llength $lpstatids] > 0 } {
set spawn_id [pop lpstatids]
log_user 1
expect eof
log_user 0
wait
if { [llength $printers] > 0 } {
spawn lpstat -p[pop printers]
lappend lpstatids $spawn_id
}
}