Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple bash print filter

Status
Not open for further replies.

dabits

Programmer
Apr 28, 2000
18
US
Hi!

I'm trying to use create a simple print filter with bash on Red Hat Linux. The filter is to work with CUPS, using "System V type script" interface. The printer is emulating an Epson FX 1050. The original problem was when using CUPS PPD, the printer is too slow. I also can't use "raw" que because I need to do a form feed and end of job. So I'm trying to use a simple script as a filter. I'm trying to use the following script:

#! /bin/bash

#set debug
set -x

#set input
[ -n "$6" ] && exec <"$6"

#initialize printer
echo -en "\030\100"

#process input
while read line; do
# replace tabs with spaces
sed -u 's/ / /g' $line
echo $line
done

# form feed after printing
echo -en "\f"

The problem is that on a 3 page report, the first page is compressed to left margin (not doing horizontal spacing properly - tabs or spaces) and part of the first page is placed at end of report! Pages 2 and 3 are okay. Without the sed line, all pages are compressed to left and I get some weird error at the end of the report. There is probably something wrong with the script but I just don't see it. Any ideas?

Thanks!!
 
Have you tried to replace this:
while read line; do
# replace tabs with spaces
sed -u 's/ / /g' $line
echo $line
done
By this ?
# replace tabs with spaces
sed -u 's/ / /g'
You my also have a look at the pr man page.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top