Operating System - HP-UX
1825775 Members
1914 Online
109687 Solutions
New Discussion

Script for resetting the printers after paperjam

 
SOLVED
Go to solution
Victor_101
Regular Advisor

Script for resetting the printers after paperjam

Hi guys , my organisation has around 100 printers and the users are accessing them 24*7. Every now and then we either a user turns off the printer or it gets jammed , as a result we have administrators on shifts to enable them every time one goes down/not accepting , but first we have to clear the queue.I have looked for a solution for this to be automated and the only way out is to run a cron job with this script for those specific printers which keep going offline. I dont really have time to play with shell scripting right now so if anyone can please help me out, i would be grateful.

Victor
11 REPLIES 11
Peter Godron
Honored Contributor

Re: Script for resetting the printers after paperjam

Victor,
can't you give the users a restricted SAM session to do the work themselves.
They would only have access to the printer submenu and could reset the queues.
Regards
Victor_101
Regular Advisor

Re: Script for resetting the printers after paperjam

not an option Peter ,these are users in administration who are not very tech savvy ( hence cancelling jobs by turning off the printer)... who are on windows . and my server OS is HP-UX .. how do i give them an interactive SAM like say Exceed , these users are just using ORacle Apps.
Peter Godron
Honored Contributor
Solution

Re: Script for resetting the printers after paperjam

Victor,
if you are going to use the cron solution something like this may help:

cancel -e `lpstat -a | grep -e "not accepting" | cut -f1 -d' '`

Explaination:
cancel -e : empties all queues on a printer
lpstat -a : acceptance status of lp destinations
grep : filters the output for failed printers
cut : extracts the printer name
Regards
Bill Hassell
Honored Contributor

Re: Script for resetting the printers after paperjam

Any user can enable any printer. The enable (and the disable) command is from section 1 of the Unix set so it is unrestricted. If a printer goes offline and causes the printer script to return a non-zero value, it is automatically disabled. But the printer can only reject new print jobs when the lp administrator (or root) uses the reject command. This prevents print jobs from beijng queued (immediate failure for the program trying to print).

So here is the problem: There are 10 jobs queued for the printer. A user sees that they are printing junk and turns off the printer. Depending on the connection, the printer may get disabled. So an automatic re-enable will start printing the junk from the beginning. If a script clears the queue, then users will call saying that the printer isn't working, and will keep sending the same print requests over and over again.

There are just too many scenarios to adequately script a simple solution. Now modern HP LaserJet printers have a cancel feature. What this does is to absorb the entire print job and do nothing, then start printing the next job. The spooler thinks all is well and continues. This is probably the best solution although it may mean replacing a lot of printers.

Otherwise, the script will have to be smart enough to cancel the current job and enable the printer. You'll still have printer issues with untrained users.


Bill Hassell, sysadmin
David DeWitt_2
Frequent Advisor

Re: Script for resetting the printers after paperjam

Victor,

You could use Exceed to give them a SAM interface, but if you have a lot of users that could get a little expensive. I can describe some of the steps using exceed if you like. I used it at my last job.

You could more cheaply set up a batch file on their desktop that initiated a telnet session to the UX server. Give them an ID that immediately starts a restricted SAM interface and then kicks them out when they exit. Of course you will not have any guarantee that they won't purge someone else's jobs from a different queue.

You may have to do some scripting regardless. If you provide some more details, I'm sure there's someone who can provide some sample scripts if I can't.

Good luck,

-dave
David DeWitt_2
Frequent Advisor

Re: Script for resetting the printers after paperjam

By the way, does your organization have a 24X7 Helpdesk or network/ops monitoring group? With a good script and/or a little training you could get that team up to speed and let them handle it. In a well organized shop they are likely to have a tiketing system that can report the workload, frequency, location, etc. of all the printer issues. That can be handy information for management, employee justification, project justification, etc.

just a thought
-dave
Florian Heigl (new acc)
Honored Contributor

Re: Script for resetting the printers after paperjam

I'd do a find -ctime +0 over /var/spool/lp/requests, cut the printer name out, merge it with the printers that have >3 request older than 1h in lpstat -o and disable / enable it.

Log this into an array and if counter is reached do
disable $prnt
cancel $prnt
lpshut
lpstart || logger -p crit "Spool DID NOT come up"
enable $prnt
reset counter
yesterday I stood at the edge. Today I'm one step ahead.
Victor_101
Regular Advisor

Re: Script for resetting the printers after paperjam

Hi guys,
thanks for the respones, will assign points before I close the thread. Peter , I would like something like the script you sent me but i would like something like a IF and THEN kind of script where I can query just a few of my 100 odd printers every 5 mins.. I feel lpstat -a every 5 mins would be a bit of a load on the system , hence my approach. The algorithm would be something like
If $printerA is down/not accepting
then
{ Cancel -e $printerA
Enable $printerA
Accept $printerA
}

and so on for all 5 printers.
We are trying to avoid having a 24/7 Support group.
A script for the above algorithm would best suit my organisation.
Thanks again
Victor
Peter Godron
Honored Contributor

Re: Script for resetting the printers after paperjam

Victor,
for a FIRST draft see attachment.
Any comments/suggestions for improvement.
Let us know if you need further assistance.
Victor_101
Regular Advisor

Re: Script for resetting the printers after paperjam

what is
"check the length of the data"
and
else " one datastring is null length"
?
Peter Godron
Honored Contributor

Re: Script for resetting the printers after paperjam

Victor,
check the length of the data:
check that the printer name passed on the command line is > 0 characters and also that the printer name given is return by the lpstat command (i.e. the printer is marked as not accepting)

one data string is null length:
Message if the above check fails

Regards