Getting Options to Pass to a Script Based Filter

Paul pconklin at gentlemanslife.com
Thu Oct 21 19:58:16 PDT 2010


> > So thanks to my last post, I at least have my script based filter working.  on to step 2.  Ideally to keep from making hundreds of PPD's and filters, I wanted to create options in my PPD so I can make my script flex based on what was chosen.  Example:
> >
> > *OpenUI *MOUNTFORM: PickOne
> > *OrderDependency: 10 AnySetup *MOUNTFORM
> > *DefaultMOUNTFORM: Normal
> > *MOUNTFORM Normal: "^XA^PON^XZ"
> > *MOUNTFORM Reversed: "^XA^POI^XZ"
> > *CloseUI: *MOUNTFORM
> >
> > That was my first pass at just inserting zpl into the job (which is not what I'm ultimately trying to do.  Ideally I just want to pass what they selected to my script (perhaps in $5?) and I can do my ksh magic based off that (like inserting those special ascii values).  If anyone can provide advice or point me to a doc, it would be much appriceated.  Ideally I want to do something like
> >
> > *OpenUI *MOUNTFORM: PickOne
> > *OrderDependency: 10 AnySetup *MOUNTFORM
> > *DefaultMOUNTFORM: Normal
> > *MOUNTFORM Normal: "NORMAL"
> > *MOUNTFORM Reversed: "REVERSED"
> > *MOUNTFORM 200DPI: "200DPI"
> > *MOUNTFORM 400DPI: "400DPI"
> > *CloseUI: *MOUNTFORM
> >
> > Then I can parse through what options they selected (moving to a PickMany, but for now using PickOne to get started)
> >
> > Thanks in advance.
>
> I may have figured out how to do this, but I'm curious if anyone has a better way.  since there is an environment variable that points to the path of the PPD, I suppose I could cat <ppdfile> | grep '*DefaultMOUNTFORM:' | cut -f 2 -d ":", but that kinda seems like a hack way, is there a better way?
>

In case inquiring minds would like to know, here is how I accomplished this.  I created "dummy" options in my ppd i.e.

*OpenUI *zbdyn16cust: Boolean
*Defaultzbdyn16cust: False
*zbdyn16cust True/T:
*zbdyn16cust False/F:
*CloseUI: *zbdyn16cust

I then use lpoptions in my script to pull them back out

lpoptions -l -dcerprint | grep *True | cut -f 1 -d ":" | cut -f 1 -d "/"

you could also grep off the default values if you weren't doing true/false

anywho, i think I have this wrapped up :-)







More information about the cups mailing list