Help with a own filter

  • Rafael

    Rafael - 2010-04-23

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

    replace "@PJL SET USERCODE = \"\"" "@PJL SET USERCODE = \"0002\"" "%%BeginFeature: *UserCode None" "%%BeginFeature: *UserCode \"0002\""

    saved as /usr/lib/ifhp/mkc

    My /etc/printcap is:
        :ifhp=model=hp8150,status,pagecount, of_options=pagecount:\
    #    :filter=/usr/lib/ifhp/ifhp:\

    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
    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:

    replace ….

    IMHO this is more easy to debug.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks