Adjust some perl & tcl related things in various scripts & utilities.
[dragonfly.git] / share / examples / printing / netprint
1 #!/usr/pkg/bin/perl
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
12 require '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
20 socket(PRINTER, &PF_INET, &SOCK_STREAM, $protocol)
21     || die "Can't create TCP/IP stream socket: $!";
22 connect(PRINTER, $sockaddr) || die "Can't contact $printer_host: $!";
23 while (<STDIN>) { print PRINTER; }
24 exit 0;