Adjust some perl & tcl related things in various scripts & utilities.
[dragonfly.git] / share / examples / printing / netprint
CommitLineData
52b73b16 1#!/usr/pkg/bin/perl
984263bc
MD
2#
3# netprint - Text filter for printer attached to network
4# Installed in /usr/local/libexec/netprint
5#
6
7$#ARGV eq 1 || die "Usage: $0 <printer-hostname> <port-number>";
8
9$printer_host = $ARGV[0];
10$printer_port = $ARGV[1];
11
12require 'sys/socket.ph';
13
14($ignore, $ignore, $protocol) = getprotobyname('tcp');
15($ignore, $ignore, $ignore, $ignore, $address)
16 = gethostbyname($printer_host);
17
18$sockaddr = pack('S n a4 x8', &AF_INET, $printer_port, $address);
19
20socket(PRINTER, &PF_INET, &SOCK_STREAM, $protocol)
21 || die "Can't create TCP/IP stream socket: $!";
22connect(PRINTER, $sockaddr) || die "Can't contact $printer_host: $!";
23while (<STDIN>) { print PRINTER; }
24exit 0;