From: Jerry Brady <jerry.brady () faypwc ! com>
To: tru64-unix-managers
Subject: SUMMARY: script for printer control from a menu
Date: Fri, 08 Dec 2000 13:32:03 +0000 [thread overview]
Message-ID: <97628236424521.tru64-unix-managers.marc@archive.invalid> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: multipart/mixed; boundary="------_=_NextPart_000_01C0611B.43B55BF8", Size: 4423 bytes --]
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_000_01C0611B.43B55BF8
Content-Type: text/plain;
charset="iso-8859-1"
Many thanks to Hajnik Ferenc for sharing his script with me.
<<lpl>>
------_=_NextPart_000_01C0611B.43B55BF8
Content-Type: application/octet-stream;
name="lpl"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="lpl"
#!/bin/sh=0A=
=0A=
PRNS=3D`cat /etc/printcap | grep -v '#' | grep '|' | awk -F\| '{ print =
$1}'`=0A=
ROW=3D0=0A=
PRN=3D""=0A=
JOBS=3D""=0A=
JOB=3D0=0A=
JSEL=3D0=0A=
QUIT=3D0=0A=
Vari=3D""=0A=
CM=3D""=0A=
export PRNS ROW PRN JOBS JSEL JOB QUIT Vari CM=0A=
=0A=
=0A=
PATH=3D/usr/sbin:/usr/bin:$PATH ; export PATH=0A=
=0A=
=0A=
Separator() {=0A=
echo =
"_______________________________________________________________________=
_________"=0A=
}=0A=
HeaderL() {=0A=
clear=0A=
echo " \t\t\t Available Printers: "=0A=
Separator=0A=
echo =0A=
echo "ID:\t Name\t\tQ. Stat\tPrinting Queues"=0A=
Separator=0A=
}=0A=
HeaderJ() {=0A=
clear=0A=
echo " \t\t\t Current Queues: "=0A=
Separator=0A=
echo =0A=
echo "No. Pri Owner Job Files\t\t\t\t Total Size"=0A=
Separator=0A=
}=0A=
=0A=
=0A=
PrintList(){=0A=
=0A=
=0A=
ROW=3D0=0A=
PRNS=3D`cat /etc/printcap | grep -v '#' | grep '|' | awk -F\| '{ print =
$1}' 2>/dev/null`=0A=
=0A=
if [ -z "${PRNS}" ] ; then=0A=
exit 1=0A=
fi=0A=
=0A=
HeaderL=0A=
for i in ${PRNS}=0A=
do=0A=
ROW=3D`expr $ROW + 1`=0A=
GV=3D`lpstat -p ${i} | grep -v "${i}:" | awk '{ print $3,$6 }' `=0A=
QS=3D`lpc status ${i}| grep -v ${i}| grep -v daemon |grep -v =
1999|grep -v is|awk '{ print $1 }'`=0A=
if [ "X${QS}" =3D 'Xno' ] ;then=0A=
QS=3D0=0A=
fi=0A=
echo "${ROW}.\t ${i}\t\t"${GV}\\t ${QS}=0A=
done=0A=
Separator=0A=
} # end PrintList=0A=
=0A=
=0A=
Select() {=0A=
SEL=3D0=0A=
OK=3D0=0A=
PRN=3D""=0A=
echo -n "Please select a Printer from 1 to $ROW (0=3Dquit): " =0A=
read SEL=0A=
while ( expr \( "${SEL}" \< "0" \) \| \( "${SEL}" \> "${ROW}" \) =
2>/dev/null ) ; do=0A=
PrintList=0A=
echo -n "Please select a Printer from 1 to $ROW (0=3Dquit): " =0A=
read SEL =0A=
done # end while=0A=
[ ${SEL} =3D 0 ] && exit 0=0A=
=0A=
SO=3D0=0A=
for i in $PRNS ; do=0A=
SO=3D`expr ${SO} + 1`=0A=
if [ ${SO} =3D ${SEL} ] ; then=0A=
PRN=3D${i} =0A=
break=0A=
fi=0A=
done=0A=
}=0A=
=0A=
SelectJ() {=0A=
SEL=3D0=0A=
OK=3D0=0A=
=0A=
JobList $PRN=0A=
echo -n "Please select a Number from 1 to $JSEL (0=3Dquit): " =0A=
read SEL=0A=
while ( expr \( "${SEL}" \< "0" \) \| \( "${SEL}" \> "${JSEL}" \) =
2>/dev/null ) ; do=0A=
JobList $PRN=0A=
echo -n "Please select a Number from 1 to $JSEL (0=3Dquit): " =0A=
JOB=3D0 =0A=
read SEL =0A=
done # end while=0A=
if [ ${SEL} -ne 0 ] ; then=0A=
=0A=
JOB=3D`echo $JOBS | awk '{ print $'${SEL}' }' ` =0A=
else=0A=
QUIT=3D1=0A=
fi # if not eq 0=0A=
}=0A=
=0A=
JobList() {=0A=
=0A=
HeaderJ=0A=
=0A=
OLDFS=3D$FS=0A=
IFS=3D'=0A=
'=0A=
JOBS=3D""=0A=
JSEL=3D0 =0A=
for i in `lpstat -o ${1} | egrep "[0-9]st|[0-9]nd|[0-9]rd|[0-9]th"` ; =
do=0A=
JSEL=3D`expr $JSEL + 1 ` =0A=
echo $i=0A=
OOIFS=3D$IFS=0A=
JOBS=3D"$JOBS `echo "$i" | awk '{ print $4}'`"=0A=
IFS=3D$OOIFS=0A=
done=0A=
IFS=3D$OLDFS=0A=
Separator=0A=
} # end Job List=0A=
=0A=
=0A=
=0A=
while : =0A=
do=0A=
IFS=3D'=0A=
'=0A=
PrintList=0A=
Select =0A=
QUIT=3D0=0A=
while [ ${QUIT} -eq 0 ] ; do=0A=
SelectJ=0A=
if [ ${QUIT} -eq 0 ] ; then=0A=
clear;=0A=
echo ; echo ;echo ;echo ;=0A=
echo "\t\t What do you want to make with this Job?"=0A=
echo=0A=
echo "\t\t 1 =3D Restart the printer "=0A=
echo -n "\t\t 2 =3D Remove cruft files "=0A=
read Vari=0A=
if [ ${Vari} -eq "1" ] ; then =0A=
echo "This Printer: ${PRN} will kill (if possible) and =
restart the spooling daemon"=0A=
CMD=3D"lpc restart ${PRN}"=0A=
(sh -c ${CMD} )=0A=
sleep 5=0A=
fi # if f =0A=
if [ ${Vari} -eq "2" ] ; then =0A=
echo "\t\t On this Printer: ${PRN} will remove cruft files =
from the queue "=0A=
CMD=3D`lpc clean ${PRN}` =0A=
(sh -c ${CMD} )=0A=
sleep 5=0A=
fi # if d=0A=
fi # if Quit=0A=
done=0A=
done =0A=
------_=_NextPart_000_01C0611B.43B55BF8--
reply other threads:[~2000-12-08 13:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox