Re: Dumb printing question
- From: The Natural Philosopher <a@xxx>
- Date: Thu, 13 Dec 2007 09:15:33 +0000
mkitchin.public@xxxxxxxxx wrote:
On Dec 12, 11:11 am, The Natural Philosopher <a...@xxx> wrote:Could you restate the original question?
I missed it and may be be able to help.
Done a lot of special printer q's on Unix/Linux..
Sure. See below. I think I may have found a hack that does what I
need. In mf_wrapper, if I comment out this line rm -f "$TMP_FILE", it
seems to leave a copy of the poscript print job in there, and I can
work with that.
Yes, or you can take the bull by the cojones and simply ditch both scripts..and substitute your own.
I now have a 'medical device' at a hospital that
I manage. It is running RedHat 7.3. I got root on the box, but I
can;t
really make any major changes. I tried starting CUPS, and that really
put it in an unhappy place. My goal is to get a postscript file on
that I can then convert to a pdf using ps2pdf. This 'device' only
likes to send to a HP network printer. We are a paperless company, so
I need to get it to a PDF and do other things with it besides
printing
it. The contents of printcap.local are below. I have looked at both
the scripts involved, and understand basically what they are doing. I
just need to figure out how to stop the process and leave the file in
a folder so I can convert the ps to a pdf and then ftp it somewhere.
I'm sure this is simple, but I'm about to pull my hair out. Can
anyone
pelase help?
Thanks,
Matthew
Pk..in essence the printcap takes the oputput file runs it THROUGH the 'if=' bit and then pipes that to stdin of the 'lp=|'
If you do not want to print at all, merely save the file somewhere else, then make :lp=/dev/null and replace mf_wrapper with a script/program that simply cats the file to a unique filename.
If you want to split the output and both drive the printer and save a file copy then look at the jetdirectprint script..
cat printcap.local:
R2printer:\
:ml=0:\
:mx=0:\
:sd=/var/spool/lpd/R2printer:\
:af=/var/spool/lpd/R2printer/R2printer.acct:\
:sh:\
:lp=|/usr/share/printconf/util/jetdirectprint:\
:lpd_bounce=true:\
:if=/usr/share/printconf/util/mf_wrapper:
----------------------------------------------------------------------
[root@R2CADSERVER util]# cat jetdirectprint
#!/usr/bin/perl
# Direct-to-printer (old HP Jetdirect style printers) filter
# to integrate with rhs-printfilters.
# Supplied by Joshua Buysse, University of Minnesota
# needs perl 5.004 for IO:Socket
require 5.004;
# Maximum number of times to retry connection
$max_retries = 3600; # at one second each, one hour.
# needed for the dirname() function
use File::Basename;
use IO::Socket;
$config_file = "script.cfg";
open(CONFIG, $config_file) || die "No config file found!";
while (<CONFIG>) {
chomp;
s/#.*//; # no comments
s/^\s+//; # no leading white
s/\s+$//; # no trailing white
# If there's nothing left, we're done.
next unless length;
# split the fields
my ($key,$value) = split /\s*=\s*/, $_, 2;
$config{$key} = $value;
}
# the config hash should contain port and printer_ip as keys
# if the port isn't set, use the default of 9100
$config{'port'} = 9100 unless $config{'port'};
$config{'printer_ip'} || die "Config file does not specify printer
IP.";
# now, open a socket to the printer.
$retry_count = 0;
do {
$socket = IO::Socket::INET->new(PeerAddr => $config{'printer_ip'},
PeerPort => $config{'port'},
Proto => "tcp",
Type => SOCK_STREAM);
if (! $socket) {
sleep 1;
$retry_count++;
}
} until ($socket || ($retry_count > $max_retries));
$socket || die "Unable to open socket after $retry_count retries.";
Somewhere about here open a file name
while (<STDIN>) {
print $socket $_;
and in here print also to it
}
close($socket);
and close the file.
My PERL is nonexistent, so don't ask me for syntactically correct PERL.
----------------------------------------------------------------------
[root@R2CADSERVER util]# cat mf_wrapper
#!/bin/bash
#
# Wrap calls to magicfilter, so that we can compose mf rules.
#
#
# Collect the rule set, as it exists _NOW_
MF_RULE_DIR='/usr/share/printconf/mf_rules'
MF_RULES=$MF_RULE_DIR/mf[[:digit:]][[:digit:]]-*
TMP_FILE=`mktemp /tmp/printconf.XXXXXX` || exit 1
# Create an m4 rule to pass the options to lpdomatic
# via magicfilter.
OPT_FILE=`mktemp /tmp/printopt.XXXXXX` || exit 1
echo 'define(LPRNGOPTS, `'$*"')dnl" > $OPT_FILE
cat $OPT_FILE ./mf.cfg $MF_RULES | m4 > $TMP_FILE
# Find the effective language set to use.
LANG=`grep '^[[:space:]]*#[[:space:]]*FILTER_LOCALE=' ./mf.cfg | sed
's/^[[:space:]]*#[[:space:]]*FILTER_LOCALE=//;'`
[ -z "$LANG" ] && LANG=C
export LANG
# Try to close up some information exposure, and set the papersize for
ghostscript
GS_PAPERSIZE=`grep '^[[:space:]]*#[[:space:]]*GS_PAPERSIZE=' ./mf.cfg
| sed 's/^[[:space:]]*#[[:space:]]*GS_PAPERSIZE=//;'`
GS_OPTIONS="$GS_OPTIONS -dPARANOIDSAFER -sPAPERSIZE=$GS_PAPERSIZE"
export GS_OPTIONS
# Tell ghostscript where it might expect to find some fonts (bug
#61015).
GS_FONTPATH=/usr/share/fonts
export GS_FONTPATH
# Debug expansion
DEBUGSTRING=
if [ -n "$DEBUG" ]
then
while [ "$DEBUG" -gt 0 ]
do
DEBUG=$(($DEBUG - 1))
DEBUGSTRING="$DEBUGSTRING --debug"
done
fi
# Run magic filter
/usr/bin/magicfilter-t "$TMP_FILE" $DEBUGSTRING < /dev/stdin
RETVAL=$?
This bit could also be used to patch into.
if [ -f "$TMP_FILE" ]; then
rm -f "$TMP_FILE"
You probably want to copy the temporary file to something a bit more meaningful like a file with the time and date in its name somewhere.
If you have a networked drive system set up (NFS? Samba) you could copy directly to a remote volume..
fi.
if [ -f "$OPT_FILE" ]; then
rm -f "$OPT_FILE"
fi
if [[ $RETVAL -eq 0 ]]; then
# what termination are we using?
TERMINATION=`grep '^[[:space:]]*#[[:space:]]*TERMINATION=' ./
mf.cfg | sed 's/^[[:space:]]*#[[:space:]]*TERMINATION=//;'`
if [ -n $TERMINATION ]; then
echo -n -e $TERMINATION;
fi
fi
exit $RETVAL
- References:
- Dumb printing question
- From: mkitchin . public
- Re: Dumb printing question
- From: Unruh
- Re: Dumb printing question
- From: mkitchin . public
- Re: Dumb printing question
- From: The Natural Philosopher
- Re: Dumb printing question
- From: mkitchin . public
- Dumb printing question
- Prev by Date: Re: "wget" files with random letters?
- Next by Date: Hot Sell Sports Shoes,Fashion Cloth,Children Shoes,Menswear,Leisure Jean
- Previous by thread: Re: Dumb printing question
- Next by thread: Re: Dumb printing question
- Index(es):
Relevant Pages
|