Hello
I would like to know how can I get the list of pending jobs in a given
printer queue with ruby.
Thanks
regards
Hello
I would like to know how can I get the list of pending jobs in a given
printer queue with ruby.
Thanks
regards
On Thu, Feb 28, 2008 at 1:30 PM, Paulo C. [email protected]
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.
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 S. wrote:
On Thu, Feb 28, 2008 at 1:30 PM, Paulo C. [email protected]
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.
On Thu, Feb 28, 2008 at 9:08 AM, Paulo C. [email protected]
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.mspx?mfr=true
You can also use my Ruby-WMI gem, which wraps win32ole and provides an
API similar to ActiveRecord. Here are some code samples:
require ‘ruby-wmi’
WMI::Win32_PrintJob.find(:all).each{ |job|
job.properties_.each{ |prop|
puts “#{prop.name}: #{job[prop.name]}”
}
}
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:
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:
require 'ruby-wmi'
WMI::Win32_PrintJob.find(:all).each{ |job|
puts “Name: #{job.name}”
puts “PagesPrinted: #{job.PagesPrinted}”
puts “TotalPages: #{job.TotalPages}”
}
Name: \server\printer, 191
PagesPrinted: 0
TotalPages: 3
Hope that helps.
Gordon
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs