Edward J. Sager on Mon, 9 Aug 1999 13:48:16 -0400 (EDT) |
I don't know if this helps, but here is a PERL script that can print directly to a JetDirect device. I got this from RedHat's site and modified it slightly to be callable by lpr. It assumes the IP address of the JetDirect card is lpsample.yourdomain.com or whatever. You can integrate into lpr with the directions below or just pipe binary output right to this script. If you want to integrate in lpr, make the directory "/var/spool/lpd/lpsample and add the following lines to /etc/printcap: lpsample:\ :sd=/var/spool/lpd/lpsample:\ :lp=/dev/null:\ :if=/etc/lpsample.pl: Then create the following PERL script in /etc/lpsample.pl #!/usr/bin/perl ($them,$port) = @ARGV; # your printer initializations here $dpi300 = "\x1B*t300R"; $dosCr = "\x1B&k3G"; $ends = "\x0A"; # set defaults in case no command line options $port = 9100; $them = "lpsample.yourdomain.com"; $AF_INET = 2; $SOCK_STREAM = 1; $SIG{'INT'} = 'dokill'; $sockaddr = 'S n a4 x8'; chop($hostname = `lpsample`); ($name,$aliases,$proto) = getprotobyname('tcp'); ($name,$aliases,$port) = getservbyname($port,'tcp') unless $port =~ /^\d+$/;; ($name,$aliases,$type,$len,$thisaddr) = gethostbyname($hostname); ($name,$aliases,$type,$len,$thataddr) = gethostbyname($them); $this = pack($sockaddr, $AF_INET, 0, $thisaddr); $that = pack($sockaddr, $AF_INET, $port, $thataddr); if (socket(S, $AF_INET, $SOCK_STREAM, $proto)) { # print "socket ok\n"; } else { die $!; } # Give the socket an address. if (bind(S, $this)) { # print "bind ok\n"; } else { die $!; } # Call up the server. if (connect(S,$that)) { # print "connect ok\n"; } else { die $!; } # Set socket to be command buffered. select(S); $| = 1; select(STDOUT); # I didn't want a banner # print S "@PJL ECHO Hi $hostname! $ends"; # print S "@PJL OPMSG DISPLAY=\"Job $whoami\" $ends"; # print S $dpi300; # Avoid deadlock by forking. if($child = fork) { print S $dosCr; print S $TimesNewR; while (<STDIN>) { print S; } print S "\f"; sleep 3; do dokill(); } else { while(<S>) { print; } } sub dokill { kill 9,$child if $child; } _______________________________________________ Plug maillist - Plug@lists.nothinbut.net http://lists.nothinbut.net/mail/listinfo/plug
|
|