cups interview questions
Top cups frequently asked interview questions
I need to print some vector data (or to be more exact: some dots and polylines) using Linux. When I ask Google for that it shows me many tutorials and documentations - but all for end users, no programming examples.
So does anybody know a good programmers HOWTO/tutorial that shows printing under Linux?
Thanks!
Source: (StackOverflow)
Is there a version of the CUPS server available for Windows? Looking at the CUPS source code it seems it is ready for Visual Studio compilation, but I did not find any trace of an actual supported package. I'd like to set up a CUPS server on Windows so that I can print form Linux/MacOSX/Win clients to printers I set up on this server.
Source: (StackOverflow)
Given a PDF, how can one get the layout mode of a PDF (or relative width/height) using a PHP lib or linux command line tool?
Using http://www.tecnick.com/public/code/cp%5Fdpage.php?aiocp%5Fdp=tcpdf which can set this variable on new PDFs, but for existing pdfs from adobe.
Thought of converting pdfs to ps, or using gs in some other way - like converting it to an image first, and getting the width and height of that. Is this the best way?
Source: (StackOverflow)
Is there a way to explicitly tell the CUPS server that the file you are sending is text/html
thus overriding the mime.types lookup?
Source: (StackOverflow)
How can I tell the lpr command (cups) that my file is actually a pdf?
lpr file.pdf
won't print anything.
Source: (StackOverflow)
With the influx of GUI applications being ported to docker, what is the best way to print to cups from inside a docker container?
NB: I am not looking to run cups from inside the container as this breaks the single service paradigm associated with docker.
Source: (StackOverflow)
I would like to print documents through http requests on Node.js. Is there any way to send print jobs and query CUPS server using Node.js. I found this project while exploring around, is it the only/correct way to do that??
Source: (StackOverflow)
I have the following Ansible playbook file, which attempts to manage the printers.conf on a set of CentOS 6 boxes.
---
# file: roles/common/tasks/config-cups.yml
# Configure printing
- name: ensure cups is installed
yum: pkg=cups state=installed
# We want to compare the local and remote printers.conf files so that
# we can predetermine if the copy needs to happen. According to a
# comment in the default printers.conf file, we can't write
# printers.conf while cups is running. But to be idempotent, we want
# to avoid stopping the cups service if we don't need to.
- stat: path=printers.conf
register: locst
- stat: path=/etc/cups/printers.conf
register: remst
# can't write printers.conf while running, so says the default file
- name: ensure cups is stopped
service: name=cups state=stopped
when: locst.stat.md5 ne remst.stat.md5
- name: Configure printers
tags: configuration
copy: >
src=printers.conf
dest=/etc/cups/printers.conf
mode=600 owner=root group=lp
notify:
- restart cups
- name: Enable the cups service
service: name=cups enabled=yes
- name: Ensure cups is running
service: name=cups state=started
Unfortunately, I receive the error "fatal: [hostxxx] => error while evaluating conditional: locst.stat.md5 ne remst.stat.md5" from the when
conditional controlling the stopping of the cups service.
Is there a way to see the values in the conditional being evaluated? Adding -vvv
hasn't helped me here.
Or is there another way of debugging the conditional?
EDIT1:
Apparently the stat module is always remote - it fails to match against the local printers.conf in roles/common/files/printers.conf
TASK: [common | stat path=printers.conf] **************************************
<hostxxx> ESTABLISH CONNECTION FOR USER[...]
<hostxxx> REMOTE_MODULE stat path=printers.conf
[...]
ok: [hostxxx] => {"changed": false, "stat": {"exists": false}}
This would be the source of my "error while evaluating conditional".
So I still don't know how to cleanly manage the file. I don't want to get into hand coding md5 values into the tasks.
This stackoverflow question is looking for pretty much the same thing.
EDIT2:
Although I'm now able to get the stat module executing against the local file, using local_action
and a longer path to work-around the lack of role-path searching in local actions, I still get the same error while evaluating conditional, despite having valid .stat.md5 values.
- local_action: stat path=roles/common/files/printers.conf
register: locst
I did, however, notice that the md5 values unexpectedly differed. It seems that during run-time, cups re-writes the printers.conf file, including, of all things, a timestamp called "StateTime". So much for a straightforward way to manage cups via writing a config file.
AFAICT, the only way to cleanly manage cups, such that it would only take down the service each time would be to either filter the existing printers.conf before comparison, or far less reasonable, to write a webscraper to operate against the interface cups wants you to use to configure printers.
Source: (StackOverflow)
I have made a custom CUPS backend in Perl. It works perfectly in 10.7-10.9, but 10.10 (Yosemite) apparently has a new sandbox feature that stops me from including a file from a subdir in "/opt".
Any suggestions are welcome!
Here is from the cups error_log:
Can't locate Net/IPP/IPP.pm in @INC (you may need to install the Net::IPP::IPP module) (@INC contains: /opt/msipp [redacted] .) at /usr/libexec/cups/backend/msipp line 73.
Here is from the system log:
sandboxd[286]: ([11381]) perl5.18(11381) deny file-read-metadata /opt/msipp/Net/IPP/IPP.pm
The complete system log entry:
perl5.18(11381) deny file-read-metadata /opt/msipp/Net/IPP/IPP.pm
Process: perl5.18 [11381]
Path: /usr/bin/perl5.18
Load Address: 0x10dd8b000
Identifier: perl5.18
Version: ??? (???)
Code Type: x86_64 (Native)
Parent Process: cupsd [10823]
Date/Time: 2014-10-09 00:15:41.756 +0200
OS Version: Mac OS X 10.10 (14A379a)
Report Version: 8
Thread 0:
0 libsystem_kernel.dylib 0x00007fff8de28a6e stat$INODE64 + 10
1 libperl.dylib 0x000000010de5241e
2 libperl.dylib 0x000000010de519cc Perl_pp_require + 3076
3 libperl.dylib 0x000000010de171ca Perl_runops_standard + 210
4 libperl.dylib 0x000000010ddaf2cd Perl_call_sv + 938
5 libperl.dylib 0x000000010ddabe46 Perl_call_list + 355
6 libperl.dylib 0x000000010dda220f
7 libperl.dylib 0x000000010dda1ef3 Perl_newATTRSUB_flags + 3620
8 libperl.dylib 0x000000010dd9c9bf Perl_utilize + 747
9 libperl.dylib 0x000000010ddd78ae Perl_yyparse + 2514
10 libperl.dylib 0x000000010ddae0c6 perl_parse + 7886
11 perl5.18 0x000000010dd8bccb main + 203
12 libdyld.dylib 0x00007fff8873d5c9 start + 1
Binary Images:
0x10dd8b000 - 0x10dd8bfff perl5.18 (103) <dd623cf6-275a-3bc8-bde0-09566702484d> /usr/bin/perl5.18
0x10dd93000 - 0x10deb7ff7 libperl.dylib (103) <8fc40e39-a06c-3454-8ada-f82bbfd179f2> /System/Library/Perl/5.18/darwin-thread-multi-2level/CORE/libperl.dylib
0x7fff8873a000 - 0x7fff8873dff7 libdyld.dylib (353.2.1) <19faf435-c165-3374-9def-d7bba7d61db6> /usr/lib/system/libdyld.dylib
0x7fff8de11000 - 0x7fff8de2efff libsystem_kernel.dylib (2782.1.97) <93e0e0a9-75b6-3904-bb4e-4bc7c05f4b6b> /usr/lib/system/libsystem_kernel.dylib
Source: (StackOverflow)
I have a script that creates a PDF document and proceed to send it to be printed. It happens that I need to wait for the document to be created, check that and recently sent for printing.
define('TIKET_DIR', public_path('temp/'));
$token = sha1(microtime().'tk');
$pdfPath = TIKET_DIR.$token.'.pdf';
$html2pdf = new HTML2PDF('V', array('72', '110'), 'es', true, 'UTF-8', 0);
$html2pdf->WriteHTML($html);
$html2pdf->Output($pdfPath, 'F');
$cmd = "lpr -P".$ococina->impresora." ";
$cmd .= $pdfPath;
$response = shell_exec($cmd);
The variable $html is dynamically created and may be delayed. Usually PDF document printed, but sometimes it does not print and I think this happens because the lpr command is executed without the PDF document is ready. I use LEMP on Ubuntu with CUPS print server. I have to turn off and turn on all printers connected to the computer and just the PDF document previously sent print.
Thanks in advance.
Source: (StackOverflow)
I have been all over stack looking at what is required to do this and have wound up being slightly confused.
Lets get one thing straight this is a local based intra-net and I do understand that PHP is server side.
I am running a company management solution on a web based PHP,JAVA,Jquery Idea. and we would like to print reports directly from the "LINUX" server and receipts etc.
I have installed cups on the server and the server is printing fine and I am now just stuck on whether or not it is actually possible to get the server to print our pdf files we are generating directly from the PHP code.
I would be happy even if we had a bash script to run and check a directory print the pdf and then delete it, even though I would see this as a work around for the time being.
Like I said I do understand that if this was done on the WWW then there would be certain exploits that could be used. If I were to run this system on the www I would have a totally different site that did not allow printing and this function would not be necessary.
Thank You in advance
Alex
Source: (StackOverflow)
What I need to do, is execute a python program/script in conjunction with user presses print, and not let the print job spool before this program quits.
Reason is that the print driver is not open source, and I need to change user settings (in this case a department id and password), that normally is per/user, but as this is a kiosk(different users with the same account) I need to make sure to reset, and prompt user before print jobs is spooled, so that different users won't pick up each others jobs.
I have created a program to handle the settings, I only need a way to start it, and not let the spool job start before the user has finished the program/settings.
I've tried to search/google this but can't really find an answer, do I need to spool the job through a cups filter first or if their is smarter way to handle this?
Source: (StackOverflow)
When i try to print document with CUPS
and xhtml2pdf
library - everything is good, but i get very slow printing. Is there any solution for this problem?
Here is Python code:
import cups
from xhtml2pdf import pisa
def main():
filename = "/home/stopfan/print.pdf"
xhtml = "<h1>Test print</h1>\n"
xhtml += "<h2>This is printed from within a Python application</h2>\n"
xhtml += "<p style=\"color:red;\">Coloured red using css</p>\n"
xhtml += "<h1>Test print</h1>\n"
xhtml += "<h2>This is printed from within a Python application</h2>\n"
xhtml += "<p style=\"color:red;\">Coloured red using css</p>\n"
pdf = pisa.CreatePDF(xhtml, file(filename, "w"))
if not pdf.err:
pdf.dest.close()
conn = cups.Connection()
printers = conn.getPrinters()
for printer in printers:
print printer, printers[printer]["device-uri"]
printer_name = printers.keys()[0]
conn.printFile(printer_name, filename, "Python_Status_print", {})
else:
print "Unable to create pdf file"
if __name__=="__main__":
main()
Source: (StackOverflow)
I have an linux app that uses cups for printing, but I've noticed that if I print and then quit my app right away my printout never appears. So I assume that my app has to wait for it to actually come out of the printer before quitting, so does anyone know how to tell when it's finished printing??
I'm using libcups to print a postscript file that my app generates. So I use the command to print the file and it then returns back to my app. So my app thinks that the document is off to the printer queue when I guess it has not made it there yet. So rather than have all my users have to look on the screen for the printer icon in the system tray I would rather have a solution in code, so if they try and quit before it has really been sent off I can alert them to the fact. Also the file I generate is a temporary file so it would be nice to know when it is finished with so I can delete it.
Source: (StackOverflow)
So I'm working with vagrant and I'm trying to use it as a printing server. I installed cups.
Internally everything works just fine. I can even make a quick curl
to my localhost:631 (cups port inside my vagrant) and there's everything.
The thing is I cant access it in any way I try from the host machine.
Obviously I forwarded the port and I've tried with several ports. I've also tried with Debian squeeze and Ubuntu 12.04. Here is my current Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "guruDebian"
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.network :forwarded_port, guest: 631, host: 6363 ## HERE IS CUPS
end
Any ideas?
Source: (StackOverflow)