1

In reference to: Redirect lpd lp to a file?

What about the scenario where you want to print and store the output in a file at the same time? I cannot seem to make this functionality work. I can get it to send to the printer, send to a text file, but I cannot get it to do both at the same time for each print job encountered. My simple of: file in /etc/printcap is:

!/bin/sh

Filter for HP Printing to do 10 pitch printing

echo "\033E\033&l0o\033(8U\033(s0p10h12v0s0b3T\033&k3G\033&s0C\c" 

cat

echo "\033E\c"

cat

I simply added to the cat command cat>>/usr/myname/store_the_text.txt. It will not do both.

Thoughts?

1 Answer 1

0

I'm not sure I fully understand the situation but here is at script which will store and print any input:

#! /bin/bash
tee >( cat > arch.$(date +%s).lpd ) | lp

I call it storeandprint and tested it with:

ls | storeandprint

The trick is the process-substitution with >( ... ). tee will send output to this >()-file and to stdout.

1
  • ok, I understand the concept, but am struggling with the syntax. I cannot use bash - using /bin/sh. Can you give me the /bin/sh command?
    – user191218
    Sep 22, 2016 at 17:44

You must log in to answer this question.

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