Changing the Ready Message on HP Printers

For April Fool's here is the quintessential program to change the ready message on an HP printer.

I've ported it to Java from the original perl program.

I'm sure you'll find all kinds of fun uses. Be careful kiddies and have fun.

A creative individual added a flickr tag so be sure to check out the gallery. Add some new ones too. Best would be some videos of interesting reactions.


package com.willcode4beer.pranks;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.text.MessageFormat;

public class HPReadyMsg {
  
  private final static String ReadyMsgFormat = "\u001B%-12345X@PJL JOB\n" +
      "@PJL RDYMSG DISPLAY=\"{0}\"\n@PJL EOJ\n\u001B%-12345X\n";
  
  public static void main(String[] args) throws Exception{
    if(args.length != 2){
      System.err.println("Usage: HPReadyMsg <ip address> \"<READY MESSAGE>\"");
      System.exit(2);
    }
    HPReadyMsg app = new HPReadyMsg();
    app.setReadyMessage(args[0], args[1]);
  }

  public void setReadyMessage(String printerAddress, String message) throws
    UnknownHostException, IOException {
    OutputStream toPrinter = new Socket(printerAddress,9100).getOutputStream();
    toPrinter.write(MessageFormat.format(ReadyMsgFormat, message).getBytes());
    toPrinter.close();
  }

}


Sponsors:

About willCode4Beer