From owner-freebsd-questions@FreeBSD.ORG Wed Sep 24 15:12:39 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 03468106567F for ; Wed, 24 Sep 2008 15:12:39 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.freebsd.org (Postfix) with ESMTP id BEF4B8FC1B for ; Wed, 24 Sep 2008 15:12:38 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.14.3/8.14.3) with ESMTP id m8OFCbIF059405 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 24 Sep 2008 10:12:38 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.3/8.14.3/Submit) id m8OFCaLm059401; Wed, 24 Sep 2008 10:12:36 -0500 (CDT) (envelope-from dan) Date: Wed, 24 Sep 2008 10:12:36 -0500 From: Dan Nelson To: Andy Kosela Message-ID: <20080924151235.GA3284@dan.emsphone.com> References: <3cc535c80809240333s1036386fnaa597267f0cf12aa@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3cc535c80809240333s1036386fnaa597267f0cf12aa@mail.gmail.com> X-OS: FreeBSD 7.1-PRERELEASE User-Agent: Mutt/1.5.18 (2008-05-17) Cc: freebsd-questions@freebsd.org Subject: Re: Netprint perl script from Handbook doesn't work X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Sep 2008 15:12:39 -0000 In the last episode (Sep 24), Andy Kosela said: > 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. Can you telnet to that ip address ("telnet 10.10.21.12 9100", or whatever port you're using)? > 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_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 () { print PRINTER; } > exit 0; Wow. That's a really complicated way to say #! /bin/sh nc $1 $2 -- Dan Nelson dnelson@allantgroup.com