[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Get pending jobs

Paulo Carvalho

2/28/2008 12:31:00 PM

Hello

I would like to know how can I get the list of pending jobs in a given
printer queue with ruby.

Thanks

regards
--
Posted via http://www.ruby-....

3 Answers

Jano Svitok

2/28/2008 1:08:00 PM

0

On Thu, Feb 28, 2008 at 1:30 PM, Paulo Carvalho <pjcarvalho@gmail.com> wrote:
> Hello
>
> I would like to know how can I get the list of pending jobs in a given
> printer queue with ruby.
>
> Thanks
>
> regards

Please post your operating system type and version/what kind of
printer queue - local, remote, etc. Be specific,
tell more details. Try to imagine you're someone else reading your
mail (omit the words 'with ruby') and try to answer it.
You see?

J.

Paulo Carvalho

2/28/2008 3:08:00 PM

0

Sorry, you are right.

I am working on a windows environment (my rails server is installed on a
windows 2000 machine). With my rails server I would like to get a list
of the jobs which are currently being processed in a printer (local or
network printer).
What is the best way to get this kink of information?

regards


Jano Svitok wrote:
> On Thu, Feb 28, 2008 at 1:30 PM, Paulo Carvalho <pjcarvalho@gmail.com>
> wrote:
>> Hello
>>
>> I would like to know how can I get the list of pending jobs in a given
>> printer queue with ruby.
>>
>> Thanks
>>
>> regards
>
> Please post your operating system type and version/what kind of
> printer queue - local, remote, etc. Be specific,
> tell more details. Try to imagine you're someone else reading your
> mail (omit the words 'with ruby') and try to answer it.
> You see?
>
> J.

--
Posted via http://www.ruby-....

Gordon Thiesfeld

2/28/2008 5:33:00 PM

0

On Thu, Feb 28, 2008 at 9:08 AM, Paulo Carvalho <pjcarvalho@gmail.com> wrote:
> Sorry, you are right.
>
> I am working on a windows environment (my rails server is installed on a
> windows 2000 machine). With my rails server I would like to get a list
> of the jobs which are currently being processed in a printer (local or
> network printer).
> What is the best way to get this kink of information?
>
> regards

The Win32_PrintJob WMI class will provide this information. You can
access WMI in Ruby using win32ole. Here's a link to a page with a
vbscript example.

http://www.microsoft.com/technet/scriptcenter/guide/sas_prn_owev.msp...


You can also use my Ruby-WMI gem, which wraps win32ole and provides an
API similar to ActiveRecord. Here are some code samples:
<code>
require 'ruby-wmi'

WMI::Win32_PrintJob.find(:all).each{ |job|
job.properties_.each{ |prop|
puts "#{prop.name}: #{job[prop.name]}"
}
}
</code>
<output>
Caption: \\server\printer, 191
DataType: RAW
Description: \\server\printer, 191
Document: document.pdf
DriverName: HP LaserJet 4250 PS
ElapsedTime: 00000000000000.000000:000
HostPrintQueue: \\10.1.53.7
InstallDate:
JobId: 191
JobStatus:
Name: \\server\printer, 191
Notify: gthiesfeld
Owner: gthiesfeld
PagesPrinted: 0
Parameters:
PrintProcessor: hpzpp38Y
Priority: 1
Size: 495840
StartTime:
Status: UNKNOWN
StatusMask: 0
TimeSubmitted: 20080228111424.908000-360
TotalPages: 3
UntilTime:
</output>

This uses the properties_ method to iterate through all of the
properties and spits them out. Once you know which properties you
want to use, you can replace them, like so:

<code>
require 'ruby-wmi'

WMI::Win32_PrintJob.find(:all).each{ |job|
puts "Name: #{job.name}"
puts "PagesPrinted: #{job.PagesPrinted}"
puts "TotalPages: #{job.TotalPages}"
}
</code>
<output>

Name: \\server\printer, 191
PagesPrinted: 0
TotalPages: 3

</output>

Hope that helps.

Gordon