Hello,
I am messing with file_output_match in order to provide our students
with some decent feedback if their file cannot be printed (e.g. yell at
them if they send an executable to the printer).
So, I set up file_output_match and the last line looks like this:
* msg yell_at_user
My first attempt was to print a simple string:
yell_at_user = User \%s{n} attempted to print \%s{J} at \%s{t}
This caused ifhp to go into an endless loop: The file output matches *
and runs the "yell_at_user' msg converter. The result gets stored in a
temporary ifhp* file. But instead of sending the results of
yell_at_user to the printer as one would expect, it runs file on the job
again and this whole process repeats until I remove the job from the
queue. Because of a bug in ifhp, I am left with hundreds of ifhp* temp
files in the spool directory. Here is a small excerpt from the status
file:
[...]
file program = '/usr/local/bin/file dfA110rachel.ece.concordia.ca' at
15:10:37.886
started FILE_UTIL- 'file' at 15:10:37.889
file information =
'ms-dos_executable_(exe),_pklite_compressed,_pkzip_sfx_archive_v2.04g'
at 15:10:37.905
initial job type
'ms-dos_executable_(exe),_pklite_compressed,_pkzip_sfx_archive_v2.04g'
at 15:10:37.905
decoded job type 'msg' at 15:10:37.906
job type 'msg', converter 'yell_at_user' at 15:10:37.906
converter done, output 26 bytes at 15:10:37.908
file program = '/usr/local/bin/file dfA110rachel.ece.concordia.ca' at
15:10:37.908
started FILE_UTIL- 'file' at 15:10:37.912
file information =
'ms-dos_executable_(exe),_pklite_compressed,_pkzip_sfx_archive_v2.04g'
at 15:10:37.927
initial job type
'ms-dos_executable_(exe),_pklite_compressed,_pkzip_sfx_archive_v2.04g'
at 15:10:37.928
decoded job type 'msg' at 15:10:37.929
job type 'msg', converter 'yell_at_user' at 15:10:37.929
converter done, output 26 bytes at 15:10:37.931
[...]
So I changed it to output PostScript:
yell_at_user = %!PS-Adobe-3.0
/Courier
findfont 10 scalefont setfont
72 500 moveto
(User '\%s{n}' attempted to print the following file:) show
72 480 moveto
( '\%s{J}') show
72 460 moveto
(At \%s{t}) show
72 440 moveto
(File cannot be printed -- unsupported file type) show
showpage
This works, no problem.
Now what I would rather do is send the student an e-mail instead of
wasting paper. After some tinkering, I changed the last line of
file_output_match to this:
* msg \%s{yell_at_user}
And also set this:
yell_at_user = /tmp/yell_at_user.pl \%s{n} \%s{t} \%s{J}
When I send an executable to the printer, I can see from the status file
that it is starting the converter with the correct parameters but I
receive no e-mail. If I cut-n-paste the command and run it by hand, a
mail message is sent, so I know the script is working correctly. As far
as I can tell, the script is not running at all:
job type 'msg', converter '/tmp/yell_at_user.pl chris
2003-07-11-16:16:40.000 sonyminf.exe 2>&1' at 16:16:41.608
converter done, output 0 bytes at 16:16:41.610
Here is my script:
$!/usr/local/bin/perl
($user, $time, $job) = @ARGV;
open(SENDMAIL, "|/usr/lib/sendmail -oi -t")
or die "Can't fork for sendmail: $!\n";
print SENDMAIL <<"EOF";
From: Chris O'Regan <[EMAIL PROTECTED]>
To: $user
Subject: Your job could not be printed
We could not print the following job at $time
$job
The printer does not support this file type.
EOF
close(SENDMAIL) or warn "sendmail didn't close nicely";
print STDOUT <<"EOF";
%!PS-Adobe-3.0
/Courier
findfont 10 scalefont setfont
72 500 moveto
(User $user attempted to print the following file:) show
72 480 moveto
( $job) show
72 460 moveto
(At $time) show
72 440 moveto
(File cannot be printed -- unsupported file type) show
showpage
EOF
exit 0
Any ideas?
Thanks,
Chris
-----------------------------------------------------------------------------
YOU MUST BE A LIST MEMBER IN ORDER TO POST TO THE LPRNG MAILING LIST
The address you post from MUST be your subscription address
If you need help, send email to [EMAIL PROTECTED] (or lprng-requests
or lprng-digest-requests) with the word 'help' in the body. For the impatient,
to subscribe to a list with name LIST, send mail to [EMAIL PROTECTED]
with: | example:
subscribe LIST <mailaddr> | subscribe lprng-digest [EMAIL PROTECTED]
unsubscribe LIST <mailaddr> | unsubscribe lprng [EMAIL PROTECTED]
If you have major problems, send email to [EMAIL PROTECTED] with the word
LPRNGLIST in the SUBJECT line.
-----------------------------------------------------------------------------