command returning a value of option

Jiri Tempir jiri.tempir at kleibl.cz
Tue Jun 5 00:50:53 PDT 2012


Hello,
>
>
> 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.
>

I also tried a PXL driver. PJL header is its output.

> 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
> --168428555-1824941642-1338556783=:15175--
>

I must apologize to you. As you cite, it's important thorough tests and I wasn't so thorough as should.
Now I know foomatic-rip much better then before.
The easiest way how to solve my problem is put the script into usercode section.
----------------------------------------------------------------------------
*UserCode 1001/1001: "%% FoomaticRIPOptionSetting: UserCode=1001"
*FoomaticRIPOptionSetting UserCode=1001: "mark\n&&
() (`usercode.sh &user;`) (20`date +%y%m%d%R | sed 's/://'`) {setuserinfo} stopped\n&&
cleartomark\n"
*End
-----------------------------------------------------------------------------
Usercode is variable A.
*FoomaticRIPOption UserCode: string CmdLine A

The variable %A in the command FoomaticRIPCommandLine is substituted by the code in the double quotes in the selected option (in my case *FoomaticRIPOptionSetting UserCode=1001).
The command printf prints string returned by the command in grave accents.
*FoomaticRIPCommandLine: "printf "%%!PS-Adobe-3.0\n%%%% %%%%\n%A%B%C%D"%%%%; cat;"

Thank you for your time.

Kind Regards
Jiří Tempír




More information about the cups mailing list