Posted By

chrisaiv on 12/23/11


Tagged

pearl


Versions (?)

Pearl: Modify text screen on HP 4100-4200 Laserjet Printers


 / Published in: Perl
 

I found this script online and thought to myself, "I must use this in the office!" All you need to do is create a nameoffile.pl file, and execute this command in your terminal. $ nameoffile.pl "Insert message"

  1. #!/usr/bin/perl
  2.  
  3. # $Id: hpsetdisp.pl 2 2008-07-10 00:05:58Z yaakov $
  4.  
  5. # hpsetdisp.pl
  6. # Connects to a JetDirect equipped HP printer and uses
  7. # HP's control language to set the ready message on the
  8. # LCD display. Takes an IP address and message on the
  9. # command line. My favorite message is "INSERT COIN".
  10. # Keep in mind the limitations of the display when composing
  11. # your clever verbiage.
  12. #
  13. # THIS PROGRAM IS PROVIDED WITH NO WARRANTY OF ANY KIND EXPRESSED OR IMPLIED
  14. # THE AUTHOR CANNOT BE RESPONSIBLE FOR THE EFFECTS OF THIS PROGRAM
  15. # IF YOU ARE UNCERTAIN ABOUT THE ADVISABILITY OF USING IT, DO NOT!
  16. #
  17. # Yaakov (http://kovaya.com/)
  18.  
  19. use strict;
  20. use warnings;
  21.  
  22. unless (@ARGV) { print "usage: $0 <ip address> \"<RDYMSG>\"\n" ; exit }
  23. if ($ARGV[3]) { print "Your New Message\n" ; exit }
  24.  
  25. my $peeraddr = $ARGV[0];
  26. my $rdymsg = $ARGV[1];
  27. chomp $peeraddr;
  28.  
  29. use IO::Socket;
  30. my $socket = IO::Socket::INET->new(
  31. PeerAddr => $peeraddr,
  32. PeerPort => "9100",
  33. Proto => "tcp",
  34. Type => SOCK_STREAM
  35. ) or die "Could not create socket: $!";
  36.  
  37. my $data = <<EOJ
  38. \e%-12345X\@PJL JOB
  39. \@PJL RDYMSG DISPLAY="$rdymsg"
  40. \@PJL EOJ
  41. \e%-12345X
  42. EOJ
  43. ;
  44.  
  45. print $socket $data;

Report this snippet  

You need to login to post a comment.