Beta Shell
v2.0 ยท web2.us.cloudlogin.co
[FM]
[CMD]
[PHP]
[DB]
[INFO]
[SEC]
File Manager
~
/
usr
/
share
/
perl5
/
vendor_perl
/
Ocsinventory
/
Agent
/
Backend
/
OS
/
Generic
/
Printers
Upload
3 items
Name
Size
Perms
Modified
Actions
[ .. / .. ]
Cups.pm
1.25 KB
-rw-r--r--
2024-10-28 14:52:47
Edit
Del
Editing: Cups.pm
(1.25 KB)
Path: /usr/share/perl5/vendor_perl/Ocsinventory/Agent/Backend/OS/Generic/Printers/Cups.pm
Back
package Ocsinventory::Agent::Backend::OS::Generic::Printers::Cups; use strict; sub check { my $params = shift; my $common = $params->{common}; # If we are on a MAC, Mac::SysProfile will do the job return if -r '/usr/sbin/system_profiler'; return unless $common->can_load("Net::CUPS") && $Net::CUPS::VERSION >= 0.60; return 1; } sub run { my $params = shift; my $common = $params->{common}; my $cups = Net::CUPS->new(); my @destinations = $cups->getDestinations(); my $printer; my $description; my $port; my $driver; foreach (@destinations) { $printer = $_->getName() unless $printer; $description = $_->getDescription() unless $description; $port = $_->getUri() unless $port; $driver = $_->getOptionValue("printer-make-and-model") unless $driver; # Just grab the default printer, if I use getDestinations, CUPS # returns all the printer of the local subnet (if it can) # TODO There is room for improvement here $common->addPrinter({ NAME => $printer, DESCRIPTION => $description, PORT => $port, DRIVER => $driver }); $printer = $description = $port = $driver = undef; } } 1;