System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

CUPS on SuSE 10. need ascii print to file

 
SOLVED
Go to solution
Highlighted
Occasional Advisor

CUPS on SuSE 10. need ascii print to file

The operating system is SuSE 10 SP3.

I need to configure an ascii printer, in CUPS version 1.1, to send its output to a file.

I've figured out how to configure a null printer but need the output to go to a specific path and filename.

There is probably a way to change something in the PPD file but I cant find a description of the various options in that file.

There is a lot of documentation about CUPS out there but all of it assumes that you want to print to an actual printer.

Any suggestions? Thanks in advance.
10 REPLIES 10
Highlighted
Honored Contributor
Solution

Re: CUPS on SuSE 10. need ascii print to file

If your CUPS version is 1.1.18 or newer, you could add a setting:

FileDevice Yes

in your /etc/cups/cupsd.conf.

This setting will allow you to create printer devices using the "file:/filename" URL, like "file:/specific/path/filename" for example.

Such a printer cannot accept print jobs of type "application/octet-stream", i.e. they must be recognizable by CUPS as something other than raw print data.

The file will contain the output of the latest print job only: subsequent print jobs will overwrite previous ones. The file will be written using the identity of the user cupsd runs as ( = usually as root).

Once you've created the necessary file printer(s), you can reset the FileDevice setting back to the default value. The FileDevice setting in /etc/cups/cupsd.conf only controls whether new file printers can be created or not; it has no effect on already existing print queues that use a printer URL of type "file:".

------------

It's also relatively simple to create your own CUPS printing backends using scripts. Here are two examples, a simple one and an advanced one:

http://osdir.com/ml/printing.cups.devel/2004-10/msg00007.html

(This was a result of googling for "cups print to file" and quickly browsing through the first three links, by the way.)

------------

If the application that produces the print-out data accepts a custom print command, you could side-step the entire CUPS printing system, by supplying as a "print command" a small script that essentially contains only a command like this:

cat > /specific/path/filename

(Normally, the application will simply pipe its print-out data to the appropriate "lp" or "lpr" command. You'll only need to make the application to pipe its print-out to a command or script that writes standard input to a file of your choosing, and your problem is solved.)

MK
MK
Highlighted
Occasional Advisor

Re: CUPS on SuSE 10. need ascii print to file

I think that is what I am looking for, I will let you know if that is the solution.

I admit this is a kludge, wasnt my idea.

Thanks!
Highlighted
Occasional Advisor

Re: CUPS on SuSE 10. need ascii print to file

After changing the FileDevice parameter in cupsd.conf I was able to create a printer with the lpadmin command:

lpadmin -p rptx -v file:/var/opt/rpt/rptx -P /usr/share/cups/model/laserjet.ppd

But when we attempt to print to this file the result is data that is not in a readable format.

Which model file will give me plain ASCII output (in the file) ?

Thanks
Highlighted
Honored Contributor

Re: CUPS on SuSE 10. need ascii print to file

The laserjet.ppd will probably produce some version of PCL printing language.

For text-only output, attached is a textonly.ppd file that comes with the standard CUPS installation on Debian 5.0. Doesn't SuSE 10 have it?

MK
MK
Highlighted
Honored Contributor

Re: CUPS on SuSE 10. need ascii print to file

Oops, looks like the textonly.ppd also requires the accompanying "textonly" filter script that should be placed into the CUPS filter directory (/usr/lib/cups/filter in Debian 5.0). Here's it.

MK
MK
Highlighted
Occasional Advisor

Re: CUPS on SuSE 10. need ascii print to file

This is working great now. The generated file is human readable.

Many Thanks!!

Now, they just need one more thing.

Can the generated file have a random number as part of the filename so we dont keep overwriting the same file ?

I tried passing the following to the lpadmin command -v option:

file:/var/opt/rpt/fsp.$$

thinking that the $$ would be replaced with the process ID every time a new output file was generated. Unfortunately this is interpreted once when the lpadmin command is executed. I also tried backslashes and quoting.

Is what I am asking for even possible ?

Thanks in advance and sorry to be a pest.
Highlighted
Acclaimed Contributor

Re: CUPS on SuSE 10. need ascii print to file

>I tried passing the following: file:/var/opt/rpt/fsp.$$
>thinking that the $$ would be replaced with the process ID every time a new output file was generated.

This is the PID of the shell, which won't change, unless a subshell is created.

>Is what I am asking for even possible?

Sure, create another dummy shell, for a real shell:
file:/var/opt/rpt/fsp.$($SHELL -c 'echo $$')
Highlighted
Occasional Advisor

Re: CUPS on SuSE 10. need ascii print to file

Close, but no cigar. This queue is always printing to a file with the same number every time.

Does CUPs, at any point, have a script that controls what the generated filename looks like ? That would be appear to be the only way to achieve this since the lpadmin command expects a literal expression as an argument to the -v option.

Thanks
Highlighted
Honored Contributor

Re: CUPS on SuSE 10. need ascii print to file

reference to the newer post:

http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1446100
****
Unix operates with beer.