[cups] Sending mail from a CentOS7 virtual machine to Fuji Xerox ApeosPort-IV C4475 problem revisted

Gernot Hassenpflug aikishugyo at gmail.com
Fri Oct 12 06:54:55 PDT 2018


On Fri, Oct 12, 2018 at 5:38 PM Gernot Hassenpflug <aikishugyo at gmail.com>
wrote:

> On Fri, Oct 12, 2018 at 4:50 PM マスターズ・イアン <ian at ncsa.jp> wrote:
>
>> > How are you at reading shell scripts?
>>
>> Not very good at all really.
>>
>
> Hi Ian,
> Ah, that is a problem for this sort of thing, as you now know.
>
>
>> or in English, somnething like:
>>
>> /usr/lib/cups/filter/fxauth.test: Line 17: Unexpected end of file (EOF)
>> while searching matching '' '
>> /usr/lib/cups/filter/fxauth.test: line 24: syntax error: unexpected end
>> of file (EOF)
>>
>
> Maybe $INPUT is empty?
> The way to test a script is to ascertain that the expected inputs exist,
> and print them out with echo for example to check.
> Then you can check the output.
> I don't know if I have time to help on the weekend, but if I do, the first
> thing I will do is just show you how to do the above.
> Best regards,
> Gernot Hassenpflug
>

Hi Ian,

I had a chance to look at the file, and found a few problems with my
documentation, sorry about that.
(1) the sed expression is missing the final ' before $INPUT.
(2) each line must be ended with a \, so final expression should be

sed -e '/@PJL COMMENT Version:4.00/ a\
@PJL SET JOBATTR="@CNAM=P10316-VM"\
@PJL SET JOBATTR="@DAID="\
@PJL SET JOBATTR="@JOAU=3496"\
@PJL SET JOBATTR="@LUNA=3496"' $INPUT

Now the logic.
1. the test file is read in as the 6th parameter
2. a temporary file is created
3. the contents of the test file are put into the temporary file
4. the sed expression appends 4 lines after the string "@PJL COMMENT
Version:4.00"

I added a couple of debug lines to the file, and commented out the PPD, so
in full for testing it is (fxauth.sh, executable):

#!/bin/bash

[ -n "$6" ] && exec <"$6"
# input is regular file
cleanup() { EXIT_CODE=$? ; rm -f $INPUT &>/dev/null ; exit $EXIT_CODE ; }
trap 'cleanup' 0 1 2 3 15

MY_NAME=${0##*/}
INPUT=$( mktemp /var/spool/cups/tmp/root.XXXXXX ) || exit 1
cat - >$INPUT

# check parameters
echo "file: $INPUT"
echo "file contents:"
cat $INPUT

# prefilter for all printjobs arriving on linux, since authentication is
not optional

#source /etc/cups/ppd/${PRINTER}.fx
#source /etc/cups/ppd/11F1.fx

sed -e '/@PJL COMMENT Version:4.00/ a\
@PJL SET JOBATTR="@CNAM=P10316-VM"\
@PJL SET JOBATTR="@DAID="\
@PJL SET JOBATTR="@JOAU=3496"\
@PJL SET JOBATTR="@LUNA=3496"' $INPUT

exit $?

Then I made a test.prn file containing:

This is a test file
@PJL COMMENT Version:4.00

And then simply ran the script as follows:

hase at hase:~$ ./fxauth.sh 1 2 3 4 5 test.prn
file: /var/spool/cups/tmp/root.ix5nS8
file contents:
This is a test file
@PJL COMMENT Version:4.00
This is a test file
@PJL COMMENT Version:4.00
@PJL SET JOBATTR="@CNAM=P10316-VM"
@PJL SET JOBATTR="@DAID="
@PJL SET JOBATTR="@JOAU=3496"
@PJL SET JOBATTR="@LUNA=3496"

As you can see the test file neatly has the lines appended.
So in your printjob you need to check if you have a similar line you can
use to append after, else you might need to change the filter, e.g., if the
version is different, or if there is just different stuff there.

I will update my documentation on my webpage now also!

Best regards,
Gernot Hassenpflug


More information about the cups mailing list