Pille
June 9, 2004, 8:48am
#1
Hi again!
I need some help again.
How do i get a list of all completed print jobs like in the browser using:
http://127.0.0.1:631/jobs?which_jobs=completed
I need this information in applescript.
I need the name of the printer, the name of the job, the time when the job was completed and the information whether the job was completed or cancelled - and maybe - if possible - the time the job nedded to be completed (end time - start time).
I made some experiments with «lpstat -W completed -o» but there i don’t get the job name just the ID and not the information whether completed or cancelled.
Any idea?
Thanx Pille :?
[/quote]
jonn8
June 9, 2004, 2:27pm
#2
Why not just use that CUPS link via curl and then parse the HTML results?
–Open this script in a new Script Editor window.
set the_HTML to (do shell script “curl http://127.0.0.1:631/jobs?which_jobs=completed ”) as string
set job_delim to “” & return & tab & “” & return & tab & “”
set the_jobs to {}
tell (a reference to my text item delimiters )
set {old_delim , contents } to {contents , job_delim }
set the_HTML to the_HTML ’s text items 2 thru -1
repeat with i from 1 to (count the_HTML )
set j to item i of the_HTML
set {p , n , u , z , s , contents } to {j ’s paragraph 1, j ’s paragraph 2, j ’s paragraph 3, j ’s paragraph 4, j ’s paragraph 7, “>”}
set {p , n , u , z , contents } to {p ’s text item 2, n ’s text item 2, u ’s text item 2, z ’s text item 2, “&<”}
set {n , u , z , s , contents } to {n ’s text item 1, u ’s text item 1, z ’s text item 1, s ’s text item 1, “<”}
set {p , contents } to {p ’s text item 1, tab }
set {s , contents } to {s ’s text item 2, “ ”}
set {s , contents } to {s ’s text items , space }
set {s , contents } to {“” & s , old_delim }
set end of the_jobs to {the_name :n , the_printer :p , the_user :u , the_size :z , the_state :s }
end repeat
end tell
return the_jobs
Jon
[This script was automatically tagged for color coded syntax by Convert Script to Markup Code ]
Pille
June 17, 2004, 7:46am
#3
Thank you!
I’ve done this and it works fine!