Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a dot matrix printer, an Epson LQ-500.

It works well with CUPS, and I use it to print listings sometimes, text files, etc.

now, I'd like to use it as a logging printer. for that, I need it to print a line, when it is appended to a file or named pipe.

I was thinking about using something like this:

tail -n1 -f file | lpr -l -h -P Epson-LQ-500

but it doesn't work, the print job is constantly held. Then I tried this:

tail -n1 -f file | lp -d Epson-LQ-500 -o raw -H immediate

and it doesn't work either, the print job is held indefinitely.

When using tail without -f, or when using cat it all works fine, but CUPS just won't let it print line-by-line.

So, how do I do that?

share|improve this question
2  
What an interesting idea... I feel like this must have been the way things were done at some point in time... so it must be possible. –  gabe. Dec 14 '11 at 21:52
add comment

3 Answers

up vote 1 down vote accepted

I kinda worked around that problem with this:

tail -n2 -f file | while read line
do
echo $line | lpr -l -h -P Epson-LQ-500
done

but I'm not sure, whether this is best practice.

share|improve this answer
add comment

The CUPS system is a printer spooler (i.e., it assumes that the printer is shared; it collects the stuff to be printed and sends it to the printer only when it is finished, in order not to delay other people's printouts when you send a page header, do 1/2 hour computing and then print the rest).

The easiest way around this would be to send the output directly to the printer device (that probably means first convincing CUPS that it should leave it alone, and making sure that the printer does understand the text sent to it).

share|improve this answer
add comment
tail -f file > /dev/lp0

assuming a parallel printer and appropriate permissions, and you can't share the printer.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.