CUFP
cacharbe
snippet
<div class="Description">This is code designed for controlling an HP printer using only IO::Socket, oh and interoffice war fare. I used it to "threaten" the global help desk. I told them that if I didn't get what I want (Access on a certain machine for a project that was two weeks past due because of their mess up) I'd make all of the printers at the world head quarters display $msg. *grin*<p> I know it's not pretty, but it works nicely for me <P> <b><i>Update: </B></I>
I included a couple of the resources I used to figure out the PJL syntax and commands used in the script.
<P>C-.</div>
<CODE>
use IO::Socket;
my $host = 'INSERT IP HERE';
my $port = '9100'; #jet direct port
my $eoln = "\x0A";
$msg = 'Insert $0.25 and Press Go to Continue';
my $sock = IO::Socket::INET->new(PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp');
die "Couldn't connect to $host on $port: $!\n" unless $sock;
print "Connected\n";
$printer{"escapeseq"} = chr(27) . "%-12345X\@PJL";
$printer{"input"} = "\@PJL OPMSG DISPLAY= \"$msg \" $eoln";
$printer{"last"} = "\x1B&k3G";
foreach $key (sort(keys %printer)){
if ($key eq "escapeseq"){
syswrite($sock, $printer{$key}, $len);
}else{
my $len = length $printer{$key};
unless(syswrite($sock, $printer{$key}. chr(27), $len) == $len) {
$sock->close;
print "Server unexpectedly closed connection\n";
last;
}
}
}
</CODE>
<a href = "http://www.hp.com/cposupport/printers/support_doc/bpl01378.html">HP site link 1</a> <p>
<a href = "http://www.hp.com/cposupport/printers/support_doc/bpl01965.html">HP site link 2</a> <p>
and you can do a search on google for <a href = "http://www.google.com/search?hl=en&lr=&safe=off&q=12345X@PJL&btnG=Google+Search">12345x@pjl</a>