Netprint perl script from Handbook doesn't work
Andy Kosela
akosela at andykosela.com
Wed Sep 24 10:58:06 UTC 2008
The netprint perl script provided in the Handbook (9.4.3.2) is not
working.. or am I missing something:
plotinus:~> cat new.txt | lp.sh
Can't contact 10.10.21.12: Address family not supported by protocol
family at /usr/local/libexec/netprint line 21.
plotinus:> cat /usr/local/libexec/netprint
#!/usr/bin/perl
#
# netprint - Text filter for printer attached to network
# Installed in /usr/local/libexec/netprint
#
$#ARGV eq 1 || die "Usage: $0 <printer-hostname> <port-number>";
$printer_host = $ARGV[0];
$printer_port = $ARGV[1];
require 'sys/socket.ph';
($ignore, $ignore, $protocol) = getprotobyname('tcp');
($ignore, $ignore, $ignore, $ignore, $address)
= gethostbyname($printer_host);
$sockaddr = pack('S n a4 x8', &AF_INET, $printer_port, $address);
socket(PRINTER, &PF_INET, &SOCK_STREAM, $protocol)
|| die "Can't create TCP/IP stream socket: $!";
connect(PRINTER, $sockaddr) || die "Can't contact $printer_host: $!";
while (<STDIN>) { print PRINTER; }
exit 0;
System is 7.0-RELEASE, I got to say it was working on 6.2-RELEASE
Best Regards,
Andy Kosela
More information about the freebsd-questions
mailing list