Files
mastering-unix-ss/chapter25/function_Linux_printing
Fabio Scotto di Santolo 4cc88d2f6e initial commit
2020-07-28 19:28:25 +02:00

28 lines
877 B
Plaintext
Executable File

function Linux_printing
{
lpc status | tail +2 | while read pqstat[1] pqstat[2] pqstat[3] junk
do
# First check the status of printing for each printer
case ${pqstat[2]} in
disabled)
# Printing is disable - print status and restart printing
echo "${pqstat[1]} Printing is ${pqstat[2]}"
lpc start ${pqstat[1]}
(($? == 0)) && echo "${pqstat[1]} Printing Restarted"
;;
enabled|*) : # No-Op - Do Nothing
;;
esac
# Next check the status of queueing for each printer
case ${pqstat[3]} in
disabled)
echo "${pqstat[1]} Queueing is ${pqstat[3]}"
lpc enable ${pqstat[1]}
(($? == 0)) && echo "${pqstat[1]} Printing Restarted"
;;
enabled|*) : # No-Op - Do Nothing
;;
esac
done
}