0

I know about this question (How do I send ASCII text to printer (over USB)?). But I'm working on something different. I'd like to be able to send text from within a bash script or Perl script to my printer.

Everything I find tells me about sending a text file to my printer. Is there any way to send text from within a script? (That way I don't have to generate the text, save it as a file, then print the file, then delete the file.)

  • What printer are you using ?? – Ruskes Aug 5 '13 at 8:40
  • Generically, to any printer. Most of the time I'm using a Brother HL 1440. – Tango Aug 5 '13 at 17:24
2

lp is able to read data from standard input, see man lp:

lp submits files for printing or alters a pending job. Use a filename of "-" to force printing from the standard input.

So if you followed the advice given in the referenced question to install a "raw" printer you should be able to run

echo "whatever text you want to print" | lp -d Generic_usbtb -
  • That works, but with a glitch. Do you know how I'd specify a line feed or carriage return? I tried "\n" as well as "\r" and they come through literally. – Tango Aug 5 '13 at 16:34
  • 1
    Found it. Use "echo -e" to enable escaped characters and with that "\n" gives me a linefeed and carriage return. – Tango Aug 5 '13 at 18:27
0

You are probably talking about RAW printing.

What is Raw Printing?

"Raw Printing", "DOS Printing", "Line Mode Printing", or generically any "Page Description Language (PDL)", are all examples of sending a series of characters directly to the printer in the printer's native language. This is the recommended approach when using jZebra because jZebra is able to bypasses the default print behavior of your web browser and allows you to "program" your own print commands.

How to Raw printing on OSX 10.8

Read the nice and clean instructions how to set it up:

enter image description here

  • That's some good information, but it's a lot of work, kind of like going around your thumb to get to your elbow. – Tango Aug 5 '13 at 16:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .