Menu

Help with a own filter

Help
Rafael
2010-04-23
2013-05-09
  • Rafael

    Rafael - 2010-04-23

    Hi all
    I have a problem with a filter.
    I have writed a very simple filter:

    #!/bin/sh
    replace "@PJL SET USERCODE = \"\"" "@PJL SET USERCODE = \"0002\"" "%%BeginFeature: *UserCode None" "%%BeginFeature: *UserCode \"0002\""

    saved as /usr/lib/ifhp/mkc

    My /etc/printcap is:
    Moraleja|Aficio:\
        :lp=192.168.2.27%9100:\
        :lpd_bounce:\
        :ifhp=model=hp8150,status,pagecount, of_options=pagecount:\
        :if=/usr/lib/ifhp/mkc:\
    #    :filter=/usr/lib/ifhp/ifhp:\
        :rp=auto:\
        :sd=/var/spool/lpd/Moraleja:\
        :af=/var/log/lpd/lp-acct:\
        :lf=/var/log/lpd/lp-errs:\
        :mx#0:\
        :sh

    It works as shell command, and also as a filter, but the file queued and send to printer is not the output of filter, but the original file without replaced terms. If I make a redirection (e.g. replace "@PJL SET USERCODE = \"\"" "@PJL SET USERCODE = \"0002\"" "%%BeginFeature: *UserCode None" "%%BeginFeature: *UserCode \"0002\"" >/tmp/output ), the output file containts the correct replaced terms.

    Please, can anyone help me?
    Thank you very much in advance

    Rafael Pérez Muñoz
    Universidad de Extremadura
    Badajoz - Spain

     
  • Bernhard R. Link

    Try looking at lpq -L to see if there are any messages about the filter, perhaps that can give a hint.

    What do you mean with "If I make a redirection"? Do you mean changing the script or running the commands you give manually?
    If you mean manually, have you checked the script is actually run? (It it is not, add some diagnostics to check that and make sure the paths are correct and the script is actually executeable).

    You could also try to make your script something like
    #!/bin/sh
    cat > /tmp/1.tmp
    replace … … < /tmp/1.tmp > /tmp/2.tmp
    cat /tmp/2.tmp

    and take a look at the generated temp files.

    Also note that filter scripts are relatively complex. Perhaps using something like magicfilter to call your filter but doing all
    the rest (like for example not filtering when it gets -c and so on). Most likely that has nothing to do with your problem but
    will otherwise make the whole more smooth (like avoiding your filter being run two times and such things)…

     
  • grumpf_

    grumpf_ - 2010-04-23

    hi Rafael,
    since you have a very simple filter you can use the following the technic:

    :lp=|/path/myfilter.sh

    myfilter.sh
    #!/bin/sh
    replace ….

    IMHO this is more easy to debug.

     

Log in to post a comment.