#!/usr/bin/perl # phubbard@computer.org 10/23/02 # # Quick hack to set the 'ready' message on HP networked printers, via the # PCL command to do so. See http://www.phfactor.net/code/hpset/ use IO::Socket; use Getopt::Std; # Variables # $string0 = "%-12345X"; $string0 = "\x1B%-12345X"; $string1 = "\@PJL RDYMSG DISPLAY="; $msg = ""; $printer = ""; $port = 0; # Parse the command line - machine, port or help getopts('m:p:h'); $printer = $opt_m || "localhost"; $port = $opt_p || 9100; if ($opt_h) { print "\nSyntax: hpset {-m machine} {-p port} string\n\n"; exit; } # Pull display string from command line $string2 = join(' ', @ARGV); if (!$string2) { die "Syntax: string argument"; } # Open the TCP connection $socket = IO::Socket::INET->new(PeerAddr => $printer, PeerPort => $port, Proto => "tcp", Type => SOCK_STREAM) or die "Couldn't connect to $printer:$port : $@\n"; # set message $msg = $string0 . $string1 . "\"" . $string2 . "\"" . "\n"; print $socket $msg; $msg = $string0 . "\n"; print $socket $msg; close($socket); exit;