simonask has asked for the wisdom of the Perl Monks concerning the following question:

#!/usr/bin/perl -w use strict; use Win32::Printer::Enum; use Win32::Printer::Enum qw( Jobs ); my $server = 'sfile'; my @printer = Printers([$server]); my $count_printer = @printer; for(my $i=0; $i < $count_printer; $i++) { my $count_job = $printer[$i]{Jobs}; my $p = $i+1; print "$p. printer: " . $printer[$i]{PrinterName} . "\n jobs: $count_job \n"; my @jobs = Jobs($printer[$i]{PrinterName}, 0, $count_job); for(my $y=0; $y<$count_job; $y++) { my $p = $y+1; print " $p. job: " . $jobs[$y]{Document} . "\n"; print " StatusNr: " . $jobs[$y]{StatusNr} . "\n\n"; } }

returns nothing.

I'm trying to get print job status from a network printer. As described on cpan : Printers($server); $server name of the server on which the printer drivers should be enumerated. without submitting parameters to Printers(); it works just finding local printers.

i've also tried submitting the server like Printers('server_name'); and Printers('server_ip'); . I'm new to perl, maybe there is a syntax error ?

Replies are listed 'Best First'.
Re: Win32::Printer::Enum - can't find network printer
by Anonymous Monk on Aug 27, 2010 at 09:42 UTC

      ah! thanks for the info.

      #!/usr/bin/perl -w use strict; use Win32::Printer::Enum; use Win32::Printer::Enum qw( Jobs ); my $server = 'sfile'; my @printer = Printers($server); my $count_printer = @printer; print $count_printer;

      gives 0
      still doesn't find network printer... this runs on win7..hm any clue is welcome

        Looking at the underlying Win32 API method EnumPrinters, you could try passing in the string

        'Print Provider!!\\Machine'

        to search the machine \\Machine for printers.

        In your case, that could be:

        my @printer = Printers("Print Provider!!\\\\$server");
        Try '//sfile'? Also check your event viewer logs for hints