A Little Office Fun With HP LaserJet Printers (INSERT COIN ... please)

| 1 TrackBack
insert-coin-printer.pngIt may be more than a month past April Fools' Day, but there's never a bad time for a little humor and laughter around the office.  After reading this post at kovaya.com, I decided to see if this innocent little trick with HP LaserJets actually works.  Sure enough, it does!  Using this Perl script, you can make the LCD screen on your HP LaserJet say whatever you want.  And to top it all off, I successfully ported the app to PHP and put a nice little front end on it for your added convenience (err, enjoyment).  Continue reading for the PHP code ...

Here's the PHP code.  Have fun, and remember, always understand what you're doing.  If your IT department frowns upon stuff like this, then you should probably think twice before trying this at the office.

<?php

// Copyright (c) 2009 Mark S. Kolich
// http://mark.koli.ch
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.

define("PORT","9100");

function showUI($ip="",$msg="INSERT COIN",$status=""){
?>
<html>
<head><title>Set HP Printer Display Message</title></head>
<body>
<?
if(!empty($status)){
?><h2><?= $status; ?></h2><?
}
?>
<form method="post" action="<?= $_SERVER['PHP_SELF']; ?>">
<strong>Printer IP Address:</strong><br/>
<input type="text" size="20" name="ip" value="<?= $ip; ?>">
<br/><br/>
<strong>Display Message:</strong><br/>
<input type="text" size="50" name="msg" value="<?= $msg; ?>">
<br/><br/>
<input type="submit" value="Set Message!">
</form>
</body>
</html>
<?
}

if( !empty($_POST['ip']) &&
!empty($_POST['msg']) ) {

$ip = $_POST['ip'];
$msg = $_POST['msg'];
$msg = addslashes($msg);

if (($longip = ip2long($ip)) !== false) {
if ($ip != long2ip($longip)) {
die("Invalid IP Entered!");
}
}
else {
die("Invalid IP Entered!");
}

$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket === false) {
die("socket_create() failed!");
}

$connection = socket_connect($socket, $ip, PORT);
if ($connection === false) {
die("socket_connect() failed!");
}

$out = "@PJL RDYMSG DISPLAY=\"$msg\"\r\n";
socket_write($socket, $out, strlen($out));
socket_close($socket);

showUI($_POST['ip'], $_POST['msg'],
"Message set successfully!");

}
else {
showUI();
}

?>

You can download the PHP here, too.  Be safe you crazy kids.

Tested (and works) on the following printers ...

  • HP Color LaserJet 5550hdn
  • HP Color LaserJet 4700
  • HP LaserJet 4350
  • HP LaserJet 9000mfp

A quick Q&A ...

  • Q: Help! My HP LaserJet says something really nasty! How do I reset the READY message?
  • A: Just power cycle the printer; when the printer resumes normal operation you'll see the ever so friendly READY message.

Did You Find this Helpful?

Did you find this post helpful, or at least, interesting?

  

Send Mark a Direct Message

If you'd like to send me a direct message, please do so below. However, I do not publicly post comments or messages submitted directly to me. So, if you're going to try to SPAM me, or my blog, you're pretty much wasting your time.

400 characters remaining

Error

About Mark

A Silicon Valley native, Mark Kolich is a full-time Software Engineer, a casual entrepreneur, and a consultant for hire. A web technologies expert, his current focus is on building powerful and robust cloud-driven web-applications using Java, PHP, Perl, AJAX, DHTML, CSS, and JavaScript. His favorite programming languages are PHP, Java and JavaScript. He uses Linux, enjoys biking to work, loves building great software, and always writes elegant, readable, and maintainable code.

1 TrackBack

Last year I wrote up a quick blog post to ring in the New Year, highlighting some of my accomplishments and failures of 2008.  In that spirit, keeping the tradition alive, here's my 2009 in a nutshell:I kicked off 2009... Read More

Twitter (@markkolich)

Translate

About this Entry

This page contains a single entry by Mark Kolich published on May 5, 2009 8:45 AM.

http://kolich.tel An Interesting Experiment: WHOIS crossed with DNS (.tel Domains and Network Solutions) was the previous entry in this blog.

Symantec AntiVirus: HOWTO Disable/Unlock Scheduled Administrator Scans is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.