Re: Printing plain text with CUPS

From: Almut Behrens (almut_behrens_at_gmx.net)
Date: 03/31/05

  • Next message: Bob Alexander: "Re: question for chrony gurus"
    Date: Thu, 31 Mar 2005 21:21:27 +0200
    To: debian-user@lists.debian.org
    
    

    On Wed, Mar 30, 2005 at 04:54:55PM -0500, John Kerr Anderson wrote:
    >
    > I have an Epson LX-300+ dot matrix printer and I only want to print plain
    > text to it. I used the "raw" queue, but then it never sends a form feed
    > to the printer after each job.
    >
    > Can anyone explain how to add a form feed string so that the printer does
    > it after each job?

    Until someone comes up with a solution showing how to make CUPS append
    the form feed itself, you could simply try the following:

    $ echo -ne "\f" | cat yourtextfile - | lp -o raw -

    If you feel that's too cumbersome to type every time, you can put it in
    small wrapper script

    #!/bin/sh
    echo -ne "\f" | cat "$@" - | lp -o raw -

    which you could name 'lpraw' or something, and place in some directory
    along your searchpath, e.g. /usr/local/bin/. (Don't forget to make it
    executable.) Then simply type

    $ lpraw yourtextfile

    You can also pipe stuff into it (like in "cat yourtextfile | lpraw"),
    in case some other app outputs the text on stdout.

    Of course, you could alternatively put a function definition in your
    shell startup

    lpraw() {
        echo -ne "\f" | cat "$@" - | lp -o raw -
    }

    The problem with the above approaches is - if you print several files
    in one go (i.e. "lpraw file1 file2 file3") - there's just _one_ form
    feed appended at the very end of all files. This may or may not be
    what you want. If you need a seperate form feed after each file, then
    you could modify the script to read

    #!/bin/sh
    for file in "$@"; do
      echo -ne "\f" | cat "$file" - | lp -o raw -
    done

    Or, if you're not averse to slightly more obfuscated code

    #!/bin/sh
    perl -pe '$_.="\f" if eof' "$@" | lp -o raw -

    ...which would concatenate all input files, with form feeds appended
    individually, before the stream is piped into a single call of lp.

    Or... dozens of other ways. Heh, this is unix... you get the idea :)

    Almut

    -- 
    To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
    

  • Next message: Bob Alexander: "Re: question for chrony gurus"