[cups.general] command returning a value of option

Johannes Meixner jsmeix at suse.de
Fri Jun 1 06:19:54 PDT 2012


Hello,

On Jun 1 03:38 Ji?í Tempír wrote (excerpt):
>>> In PPD http://www.openprinting.org/ppd-o-matic.php?driver=Postscript-Ricoh&printer=Ricoh-Aficio_MP_C3001&show=1
....
> I have tied to put my script into FoomaticRIPCommandLine bat the command
> is executed at the beginning of making a job, before making a head
> and I need to modify a job head. UserCode is placed in the head of job.
>
> ESC%-12345X at PJL SET COPIES=1
....
> @PJL SET USERCODE="11119999"
....
> %!PS-Adobe-3.0
> %% %%
> mark
> () (11119999) (201204271200) {setuserinfo} stopped
> cleartomark
> %%%!PS-Adobe-3.0
....

For a proof of concept I downloaded the above PPD
to /tmp/Ricoh-Aficio_MP_C3001-Postscript-Ricoh.ppd
and set up a test queue which prints into a file
(needs "FileDevice yes" in /etc/cups/cupsd.conf)
so that I can see what the final output is:

# lpadmin -p MP_C3001 -v file:/tmp/MP_C3001.out \
   -P /tmp/Ricoh-Aficio_MP_C3001-Postscript-Ricoh.ppd -E

Then

# echo Hello | lp -d MP_C3001 -o UserCode=Custom.12345678

results this in tmp/MP_C3001.out
---------------------------------------------------------
%!PS-Adobe-3.0
%% %%
mark
() (12345678) (201206011503) {setuserinfo} stopped
cleartomark
mark
() () (201206011503) {setuserinfo} stopped
cleartomark
%%%!PS-Adobe-3.0
....
%%BeginFeature: *CustomUserCode True
(12345678)
%%EndFeature
---------------------------------------------------------

Note that I do not get a PJL herader as you
i.e. I do not get a "@PJL SET USERCODE=..." line.

I do not know wherefrom it comes in your case.

Now I changed the FoomaticRIPCommandLine
in /etc/cups/ppd/MP_C3001.ppd as follows:
---------------------------------------------------------------------
*FoomaticRIPCommandLine: "printf "%%!PS-Adobe-3.0\n&&
%%%% %%%%\n%A%B%C%D"%%%% | sed 's/12345678/87654321/';&&
sed 's/12345678/87654321/';"
*End
---------------------------------------------------------------------

Afterwards

# echo Hello | lp -d MP_C3001 -o UserCode=Custom.12345678

results this in tmp/MP_C3001.out
---------------------------------------------------------
%!PS-Adobe-3.0
%% %%
mark
() (87654321) (201206011505) {setuserinfo} stopped
cleartomark
mark
() () (201206011505) {setuserinfo} stopped
cleartomark
%%%!PS-Adobe-3.0
....
%%BeginFeature: *CustomUserCode True
(87654321)
%%EndFeature
---------------------------------------------------------

At least for me it is possible to change the final output
but I needed a bit trial an error until I found a way
which works in this particular case (it helps a lot if
one understands how the foomatic-rip magic works ;-)

In your case you need to replace my "sed 's/12345678/87654321/'"
which I only used here as proof of concept with your filter
script which does "the right thing" for you.

Be very careful with running sed on printer data, see
http://en.opensuse.org/SDB:Using_Your_Own_Filters_to_Print_with_CUPS
"... the following steps demonstrate how important thorough tests
  are in order to prevent the correction script from causing
  more problems than it solves in the default CUPS filter system."


Kind Regards
Johannes Meixner
-- 
SUSE LINUX Products GmbH -- Maxfeldstrasse 5 -- 90409 Nuernberg -- Germany
HRB 16746 (AG Nuernberg) GF: Jeff Hawn, Jennifer Guild, Felix Imendoerffer


More information about the cups mailing list