incoming_control_filter

Help
Stefan
2009-12-02
2013-05-09
  • Stefan
    Stefan
    2009-12-02

    Hello,

    I've written a incoming control filter. It reads all job information from stdin,  takes the first letter of each input line as key and the rest of the line as the value. After modifying a value it writes back all lines to stdout. In the job control file in the spool directory I found that for ALL values returned from the script the first letter is stripped; eg. A=mith instead of A=smith; the same in the account file.

     
  • grumpf_
    grumpf_
    2009-12-02

    Hello,
    can you be a bit more verbose about
    * the software version you are using ?
    * what printcap do you use ?
    * what does "return" mean ? you are doing a tmp=/tmp/file ?

     
  • Stefan
    Stefan
    2009-12-03

    SORRY. I should know this.


    Software:

    FreeBSD 7.2  /  LPRng-3.8.32 (port)


    printcap entry:

        q320:
                :server
                :lpd_bounce
                :bk
                :sh
                :mx=0
                :ml=0
                :sd=/var/spool/lpd/%P
                :lp=lp8@pr320.xx.yy.zz..de
                :incoming_control_filter=/usr/local/libexec/filter/modifyCtrl.py


    For debugging purposes I stripped down my script: it now only reads the control information from stdin into memory and writes it  to stdout.

        #!/usr/local/bin/python
       
        import sys
       
        ctrlLines = sys.stdin.readlines()
        for ctrlLine in ctrlLines:
            sys.stdout.write(ctrlLine)


    This is the log of a print job stated as root:

        waiting for subserver to exit at 2009-12-03-08:23:22.404 ## A=<NULL> number=0 process=65126
        processing 'dfA123lpr-a', size 129, format 'f', IF filter 'none - passthrough' at 2009-12-03-08:23:22.416 ## A=oot@lpr-a+123 number=123 process=65127
        printing finished at 2009-12-03-08:23:22.416 ## A=oot@lpr-a+123 number=123 process=65127
        sending job 'oot@lpr-a+123' to lp8@pr320.xx.yy.zz.de at 2009-12-03-08:23:22.416 ## A=oot@lpr-a+123 number=123 process=65127
        connecting to 'pr320.xx.yy.zz.de', attempt 1 at 2009-12-03-08:23:22.416 ## A=oot@lpr-a+123 number=123 process=65127
        connected to 'pr320.xx.yy.zz.de' at 2009-12-03-08:23:22.419 ## A=oot@lpr-a+123 number=123 process=65127
        requesting printer lp8@pr320.xx.yy.zz.de at 2009-12-03-08:23:22.419 ## A=oot@lpr-a+123 number=123 process=65127
        sending control file 'cfL123lpr-a' to lp8@pr320.xx.yy.zz.de at 2009-12-03-08:23:22.420 ## A=oot@lpr-a+123 number=123 process=65127
        completed sending 'cfL123lpr-a' to lp8@pr320.xx.yy.zz.de at 2009-12-03-08:23:22.424 ## A=oot@lpr-a+123 number=123 process=65127
        sending data file 'dfA123lpr-a' to lp8@pr320.xx.yy.zz.de at 2009-12-03-08:23:22.424 ## A=oot@lpr-a+123 number=123 process=65127
        completed sending 'dfA123lpr-a' to lp8@pr320.xx.yy.zz.de at 2009-12-03-08:23:22.430 ## A=oot@lpr-a+123 number=123 process=65127
        done job 'oot@lpr-a+123' transfer to lp8@pr320.xx.yy.zz.de at 2009-12-03-08:23:22.430 ## A=oot@lpr-a+123 number=123 process=65127
        q320@lpr-a.xx.yy.zz.de: job 'oot@lpr-a+123' printed at 2009-12-03-08:23:22.432 ## A=oot@lpr-a+123 number=123 process=65126
        job 'oot@lpr-a+123' saved at 2009-12-03-08:23:22.432 ## A=oot@lpr-a+123 number=123 process=65126

    The use name now is "oot" not  "root".

    In the accounting file "root" is changed to "oot",  "lpr-a" to "pr-a", "modifyCtrl.py" to "odifyCtrl.py". Not changed is "q320" and the file size -b129.

        jobend '-Hpr-a' '-noot' '-Pq320'  '-b129' '-t2009-12-03-08:38:12.000' '-Cpr-a' '-JodifyCtrl.py'


    When I remove the control filter script from the printcap entry, the account file entry is:

        jobend '-Hlpr-a' '-nroot' '-Pq320'  '-b129' '-t2009-12-03-09:15:29.000' '-Clpr-a' '-JmodifyCtrl.py'

    Thanks in advance.

     
  • grumpf_
    grumpf_
    2009-12-13

    hi, i can not reproduce your problem with the current source. here is what i did:
    1. install lprng-3.8.A from sourceforge

    my test printcap, it should resemple yours with a few exceptions that do not matter here.

    <code>
    #lprng test
    lp:
                :server
                :lpd_bounce
                :bk
                :sh
                :mx=0
                :ml=0
                :sd=/var/spool/lpd/%P
                :lp=/dev/null
                :incoming_control_filter=|/tmp/test.sh
    </code>

    my test.sh
    <code>
    #!/bin/sh
    tee -a /tmp/test.data
    </code>

    I got the following output:
    <code>
    Aroot@xxxxxxxxxxxx+889
    CA
    D2009-12-13-16:37:36.063
    Hxxxxxxxxxxxxx.de
    Jinstall-sh
    Lroot
    Proot
    Qlp
    Ninstall-sh
    fdfA889xxxxxxxxxxxxx.de
    UdfA889xxxxxxxxxxxxx.de
    </code>

    no missing first character

     
  • grumpf_
    grumpf_
    2009-12-13

    /*
    mmh code does not work as advertised (how to disable these ML crap ???)
    */
    <br>

    here are the important files again:

    <br>
    <b>
    cat /etc/printcap
    </b>
    <pre>
    #lprng test
    lp:
                :server
                :lpd_bounce
                :bk
                :sh
                :mx=0
                :ml=0
                :sd=/var/spool/lpd/%P
                :lp=/dev/null
                :incoming_control_filter=|/tmp/test.sh
    </pre>
    <b>
    cat /tmp/test.sh
    </b>
    <pre>
    #!/bin/sh
    tee -a /tmp/test.data

    </pre>