Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script for print queue start

Status
Not open for further replies.

jkc924

MIS
Aug 5, 2002
35
US
Hi all,
I have been asked for a script that at login it prompts for the print queue to restart, restarts it, waits 30 seconds, does an lpstat on it and then logs the user off.

Any ideas?

I am not a script writer.

Thanks,

Judy
 
hi,

what is the problem you are experiencing ?

if you let us know the problem there may be another solution
/
 
It is a security issue. They want a user added that can only restart a print queue without having to use smit.
 
put user in printq group and use Rsh (restricted shell) would be a good way. a user stuck with Rsh as shell cannot cd, so put a link to enq in their home dir. check `man Rsh`, we don't use it.

or write a script (put in root cron) that checks for down queues every 15 minutes, try to bring up say 3 times, then mail or page an admin? avoids having to rely on an operator. might also have a later version do some troubleshooting, like ping and nslookup.

hth IBM Certified -- AIX 4.3 Obfuscation
 
Every time we send a print job to be printed using infoprint on rs6000, we are constently initializing the que's. Any suggestions on a possible config. set up wrong, or what.We have two printers, identical and only the one really acts up.

Thanks.
 
You can do this a couple ways... with a script.. to restart any queues that might be down ( might be best ).. set a crontab entry

* 0,15,30,45 * * * /usr/local/bin/queue_restart

create the script below .. and save in the /usr/local/bin.. be sure to chmod +x the file so it runs. And don't worry about having to check it too often.. the cron will log each time it has to restart a queue.. and if you're in the .forward for root email .. you should get it in your email when it does..

#!/bin/ksh
# Written by Brofish .. queue_restart
# 6/4/96 DGS
lpstat | grep -i DOWN | awk '{print$1}' > /tmp/queue_reset
printers=`cat /tmp/queue_reset`

# First see that the QDAEMON is running
lssrc -s'qdaemon' > /tmp/qdm
qstat=$(grep active /tmp/qdm | awk '{print $4}')

if [ "$qstat" > "" ]
then
continue
else
startsrc -s'qdaemon'
fi
rm /tmp/qdm

#
for a in $printers
do
qadm -U$a
echo restarting $a

done
cat /dev/null > /tmp/queue_reset
###############

Another way is to run and lpstat -t to see whats down.. then run 'smitty qstart' from a login .. select F4 to pick the queue and enter to restart it.


 
why not use sudo? let the user run only commands he needs. although running a script out of cron to bring up downed queues is faster.

here is a quick and painless q kicker script

#!/bin/ksh
dqueue=`enq -sWA | grep DOWN | cut -f1 -d' '`
for q in $dqueue
do
enq -U -P$q
done



you might want to put some logging in there so you know how many times you have reset each one... Before you criticize someone, you should walk a mile in their shoes. That way you're a mile away and you have their shoes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top