Operating System - HP-UX
1830909 Members
1721 Online
110017 Solutions
New Discussion

Problems with Interface Script for Remote Printer

 
SOLVED
Go to solution
Mike Reaser
Advisor

Problems with Interface Script for Remote Printer

I've got an Oce printer on my local network, and configured it as a remote
printer to my 11i system (rp5470) using SAM so I could get as much stuff
defaulted as possible.

The Oce is on the network via a PC interface, and thus anything that gets sent
to the printer needs to be pushed thru the ux2dos filter on the way out. I'd
like to just have the interface script deal with invoking ux2dos, due to the
facts that (a) my user base isn't all that sophisticated and (b) trying to get
everyone to remember to precede all printing with "ux2dos" seems like it's
something that could more easily be handled at the system level.

In other words, instead of forcing my users to *always* use

ux2dos <> | lp -doce

I'd like to just plop the invocation of "ux2dos" in the right place in the
Oce's interface script. However, I'm stumped as to where's the correct place
to insert the ux2dos command. Depending on what I do in the script, I get
multiple copies of my files output. Please read on...

The original interface script had, after dealing with any options passed to
it, the following:

shift; shift; shift; shift; shift

/usr/sbin/rlp -I$requestid $BSDC $BSDJ $BSDT $BSDi $BSD1 $BSD2 $BSD3 $BS
D4 $BSDw $BSDformat $BSDh $1


I first inserted the lines

ux2dos <$1 >/tmp/ux2dos$$
mv /tmp/ux2dos$$ $1

just before the rlp. This works fine if the input to lp(1) is either a single
file or an input pipe. If the lp command is for two files -- like lp a b --
then "a" would be pushed thru ux2dos but b got passed across "raw".

OK, so I changed that section of the script to

spoofles="$*"
holdRet=0

for spoolfile in $spoofles
do

ux2dos <$spoolfile >/tmp/ux2dos$$
mv /tmp/ux2dos$$ $spoolfile

#echo "Before rlp on spoolfile $spoolfile" >> /tmp/mrlptr

/usr/sbin/rlp -I$requestid $BSDC $BSDJ $BSDT $BSDi $BSD1 $BSD2 $BSD3 $BS
D4 $BSDw $BSDformat $BSDh $spoolfile
ret=$?
if [ $ret != 0 ];
then
holdRet=$ret
fi

done

This, too, works fine when lp is fed either an input pipe or a single file.
When I try printing two files at once, though, I get *FOUR* files on the
printer. Using "lp a b" again, I get an un-ux2dos-ed copy of "a", an
un-ux2dos-ed copy of "b", a ux2dos-ed copy of "a", and a ux2dos-ed copy of
"b".

If I uncomment the echo command in the middle of loop, I see only *two*
messages sent to the trace file in /tmp -- yet somehow *four* things got
thrown at the rlp command, even though the interface script showed that
we fell thru the section with rlp *twice*.

Can anyone slap me up-side the head and show me where I've screwed this up?
If two files are fed to lp for this printer, I'd like to see *two* files
get printed, both of them having gone thru ux2dos. I can underkill and
overkill this problem, but I can't just kill it.

Help? Please?

Mike Reaser
Southeastern Data Cooperative
Tucker, GA
11 REPLIES 11
Steve Steel
Honored Contributor

Re: Problems with Interface Script for Remote Printer

Hi

Try

/usr/bin/ux2dos $1 > /tmp/$$
mv /tmp/$$ $1
/usr/bin/rlp ......(as "usual")


Steve Steel

If you want truly to understand something, try to change it. (Kurt Lewin)
Mike Reaser
Advisor

Re: Problems with Interface Script for Remote Printer

Thanks for the suggestion, Steve, but it just misses.

With those lines in the script, if I push two files to the printer at once -- lp a b -- then "a" makes it thru ux2dos and looks OK when it get laid on paper, while "b" does *not* get run thru the ux2dos filter and
gets printed in "stair-step"
mode.
Sanjay_6
Honored Contributor

Re: Problems with Interface Script for Remote Printer

Steve Steel
Honored Contributor

Re: Problems with Interface Script for Remote Printer

Hi

It is always 1 file.

See this remote print

# lp -dtester *
request id is tester-4218 (4 files)
# cat /tmp/testres
/usr/sbin/rlp -Itester-4218 -J/nff /var/spool/lp/request/tester/dA4218xantia

It makes a data file of all inputs and sends that.

If you have a problem then you need to make an ordinary printer which handles multiple files on a false name and in that script do a print file by file to the real printer.

Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Mike Reaser
Advisor

Re: Problems with Interface Script for Remote Printer

Thanks to everyone for the contributions and suggestions!

I decided to turn the problem "on its side", and instead of trying to beat myself up to get ux2dos integrated into the interface script, wrote a wrapper for the "lp" command which will push files thru ux2dos when appropriate.

The wrapper is attached, for anyone curious about it.
Sandip Ghosh
Honored Contributor

Re: Problems with Interface Script for Remote Printer

Hi Mike,

Have you tried with the Script dumbplot_printer_cr , with carrige return option? You can try with that.

Sandip
Good Luck!!!
Jordan Bean
Honored Contributor
Solution

Re: Problems with Interface Script for Remote Printer

Actually, Steve, all the files are treated together in a single job (passed along as parameters $6 and on). I determined this by disabling a queue, printing multiple files at once, and finding one control file and several datafiles in the request directory (/var/spool/lp/request/).

(Realizing this for the first time, I now have modify my own scripts to properly iterate through a list if a user decides to print more than one file at a time.)


So Mike, even though rlp takes only one file parameter, it actually will process the remaining data files for the job.

Try this between the shifts and rlp:

shift; shift; shift; shift; shift
for f in $@
do
ux2dos $f > $f.tmp
mv -f $f.tmp $f
done
/usr/sbin/rlp ...


Mike Reaser
Advisor

Re: Problems with Interface Script for Remote Printer

Jordan -- Thank you, thank you, thank you! I was close on my previous attempt to sit in a loop and 'moosh' the files to be printed.

Your suggestion "did the trick" and now my Oce printer will happily print straight down the left side of the page instead of "stair-stepping".

Thanks again!
Jordan Bean
Honored Contributor

Re: Problems with Interface Script for Remote Printer

My pleasure, Mike. By the way, what model Oce are you using? I'm deveping an interface script to prepend FOL JEC headers for our Oce 8430. I'll post a copy if you're interested.
Jordan Bean
Honored Contributor

Re: Problems with Interface Script for Remote Printer

Not that it makes any difference now, but 8430 is our Symmetrix model number. The Oce model is 8465. Just thought I'd let you know in case it seemed confusing.
Jordan Bean
Honored Contributor

Re: Problems with Interface Script for Remote Printer


I promised to post our interface script for the Oce 8400 series. It supports PCL5 and PostScript options if desired. Please respond with any problems or enhancements.