Koozali.org: home of the SME Server
Legacy Forums => Suggestions => Topic started by: Paul van Dun on April 24, 2002, 12:40:20 AM
-
I would like to see printer queue management in the serverpanel, like e.g. in Novell there is a GUI to manage your printerqueues on the server that also can be ran from a client PC with the admin rights.
In the mean time is someone who can tell me what the commands are to manage a linux printer queue.
Because I'd like to remove a printertask when it's wrong or it ain't the right document.
Best regards,
Paul van Dun
-
You might get more replies if you post your question on another forum.
What I did once when a print job went berserk -- I SSHed to the server, and killed the printer daemon. When I restarted it, it had forgotten all about the old job.
I'm quite sure this isn't the proper way to do this, but it works..
-
Sign me up for the printer que managment thing too. I'd love to see one since I've had several print jobs stuck that I could only remove by restarting the server. Interestingly it will print the stuck jobs after a restart.
-
Hi all,
We have done a little improvement over the "standard" printer management code. This small enhacement allows the admin ti restart a given printer queue without needing to restart the whole server or service, just the bersek queue :))
Do you want us to make a rpm? (This wont be a good idea as it means replacing a function file).. OK, I will put the needed changes in our contrib area (eneo) ASAP. Comments are welcome.
Sorry for the "spanish" code, but you get the idea. BTW, this is done for ESSG 4.1.2
Regards
-
Let me know were to find this file and i'll be happy to test it !
regards,
Paul van Dun
-
Hi,
It doesnt need testing. Its cuyrrently working in 5 servers without a hinch. I was just offering "the code" if you think it deserves the time. I dont know if this is a good addon or just a little hack.
OK, I will put in in our ftp contrib area as soon as we can but it will take a couple of days.
Regards.
-
Can you tell what it does, or can you E-Mail it to me maybe much faster, and howto install the add-on.
Thanks
Paul
-
As this is too stupid to place it in our contrib area, here it is directly. You just need to copy and paste the code for /etc/e-smith/web/functions/printers Sorry, we made some modifications too to the standard panel to show only information relevant to local printers :)
#!/usr/bin/perl -wT
(...)
elsif ($q->param ('state') eq "restart")
{
esmith::cgi::genHeaderNonCacheable ($q,
\%conf, 'Printer queue restart');
esmith::util::serviceControl
(
NAME => 'lpd',
ACTION => 'restart',
) || die "The service did not restart. You should restart the server.";
print $q->p ('Printer service restarted successfully.');
esmith::cgi::genFooter ($q);
}
elsif ($q->param ('state') eq "empty")
{
emptyPrinter ($q);
}
(...)
#----------------------------------------
# subroutine to display initial form
#----------------------------------------
sub showinitial ($$)
{
(...)
else
{
print $q->h4 ('Current List of printers');
print $q->table ({border => 1, cellspacing => 1, cellpadding => 4});
print $q->Tr (esmith::cgi::genSmallCell ($q, $q->b ('Name')),
esmith::cgi::genSmallCell ($q, $q->b ('Description')),
esmith::cgi::genSmallCell ($q, $q->b ('Location')),
esmith::cgi::genSmallCell ($q, $q->b ('Remote address')),
esmith::cgi::genSmallCell ($q, $q->b ('Remote Name')),
$q->td (' '),
$q->td (' '));
my $printer;
foreach $printer (sort @printerDrivers)
{
my ($type, %properties) = db_get(\%accounts, $printer);
my $address = ($properties{'Location'} eq 'remote')
? $properties{'Address'} : 'N/A';
my $remoteName = ($properties{'Location'} eq 'remote')
? $properties{'RemoteName'} : 'N/A';
unless ($remoteName)
{
$remoteName = 'raw';
}
print $q->Tr (esmith::cgi::genSmallCell ($q, $printer),
esmith::cgi::genSmallCell ($q, $properties{'Description'}),
esmith::cgi::genSmallCell ($q, $properties{'Location'}),
esmith::cgi::genSmallCell ($q, $address),
esmith::cgi::genSmallCell ($q, $remoteName),
esmith::cgi::genSmallCell ($q,
$q->a ({href => $q->url (-absolute => 1)
. "?state=delete&printer="
. $printer}, 'Remove...')),
esmith::cgi::genSmallCell ($q,
$q->a ({href => $q->url (-absolute => 1)
. "?state=empty&printer="
. $printer}, 'Flush queue...')));
}
print '';
print $q->p ($q->a ({href => $q->url (-absolute => 1) . "?state=restart"},
'Click here'),
'to restart the printer service (flushes all queues).');
}
esmith::cgi::genFooter ($q);
}
(...)
#------------------------------------------------------------
#
#------------------------------------------------------------
sub emptyPrinter ($)
{
my ($q) = @_;
#------------------------------------------------------------
# Attempt to empty printer
#------------------------------------------------------------
my $printer = $q->param ('printer');
if ($printer =~ /^([a-z][a-z0-9]*)$/)
{
$printer = $1;
}
else
{
showInitial
($q,
"Error while flushing queue \"$printer\".");
return;
}
/usr/bin/lprm -P $printer all > /dev/null 2>&1;
showInitial ($q, "Queue \"$printer\" has been flushed.");
}
-
Well after some E-mailing to Jaime I've got the script to work, and believe me this is one of the best add-ons I've ever seen.
This should be standard in E-Smith in the future, just a click and your queue is flushed.
I would like to thank Jaime for his time to help me with some questions, I'm almost done translating and testing.
Regards,
Paul van Dun
The Netherlands
-
Paul,
When you get it working properly, how about posting a howto and the files? If you would prefer to email offlist that would be fine.
Cheers,
-Jeff
-
someone help me please!
I tried to copy/paste the scriptlines posted earlier and screwed my /etc/e-smith/web/functions/printers file, because I don't know anything about java/html I can't fix the wrong syntax myself.
can someone send me a working ..../printers file ???
thanx a lot in advance,
dlex
.p.s.: I will learn to hack such files, I promise! :)
-
Jaime's patch is working greatly! Thanks a lot.
Did anyone some work on displaying a queue's status? I thought of a simple "lpq -Pmyqueu", may be with a little make up?
-
Hello Micheal,
Can you also add a network printer, and if so can you send me your printer file ?
Thanks in advance
Best regards,
Paul van Dun
-
For those who don't mind the Linux command shell, the SME server already has standard Linux print queue utilities that should help (and will allow you to pick and choose WHICH print jobs are canceled, delayed, etc):
The commands are:
lpr - This command sends a file TO the print queue (e.g., 'lpr sample.txt')
lpq - Checks the status of a print job
lprm - removes a job from the print queue...
For instance, let's say you want to kill a print job sent to a printer named laserjet4:
lpq -Plaserjet4 (Returns a list of jobs queued for the printer as follows):
Printer: laserjet4@server 'HP IV L'
Queue: 1 printable job
Server: pid 5217 active
Unspooler: pid 5218 active
Status: processing 'dfA216www.yourdomain.net', size 73000, format 'f', IF filter 'none - passthrough' at 17:33:08.142
Rank Owner/ID Class Job Files Size Time
active billyjimbob@www+216 A 216 (STDIN) 73000 17:33:07
The results above show the job number for the active print job started by user "billyjimbob" is 216. To kill that print job (and ONLY that print job), type:
lprm -Plaserjet 216
Tada! The print job should come to a screeching halt now.
Hope this helps!
(Among other sources for info on lpr, lpq, and lprm, see http://www.linuxprinting.org/man/lprm.1.html)
Mike Fahy