7 # Random nonsense messages
10 "FEED ME WITH LITTLE PUPPIES",
11 "All your base are belong to us.",
12 "You're printing way too much.",
13 "Paper jam? How does that taste?",
14 "Zum Weiterdrucken Muenze einwerfen",
15 "Initiating robot uprising",
16 "E: You have exceededyour print quota"
23 # Parameter 2: PJL status readback command
24 # Returns: printers reply, or undef.
25 sub sendpjlstatusreadback($$) {
29 print($sock "\033%-12345X\@PJL $cmd\n\033%-12345X");
30 local $SIG{'ALRM'} = sub {
31 die("Status readback timed out after $mytimeout seconds.\n");
34 while (sysread($sock, $ll, 1)) {
35 #printf("0x%02x ", ord(substr($ll, 0, 1)));
36 if ($ll eq "\x0C") { # "form feed" = official End of status.
43 print("Warning: status read ended with EOF or error\n");
49 # Parameter 2: PJL status readback command
50 # Parameter 3: 0 = No Open oder Close, 1 = Send "start of PJL command",
51 # 2 = Send "end of PJL commands", 3 = Send both
53 sub sendpjlcommand($$$) {
58 $tosnd .= "\033%-12345X";
60 $tosnd .= "\@PJL $cmd\n";
62 $tosnd .= "\033%-12345X";
64 print("Sending command: '$tosnd'\n");
69 print("Syntax: $0 [printerip]\n");
72 $printerad = $ARGV[0];
73 my $SOCKET = new IO::Socket::INET(
74 PeerAddr => $printerad,
75 PeerPort => '9100', # 9100 = jetdirect
79 print("Failed to connect to printer $printerad Port 9100: $!.\n");
82 print("Connected.\n");
83 binmode($SOCKET, ':raw');
84 print(sendpjlstatusreadback($SOCKET, "INFO STATUS"));
85 print(sendpjlstatusreadback($SOCKET, "INFO PAGECOUNT"));
86 # print($SOCKET "\033%-12345X\@PJL INFO STATUS\r\n\@PJL INFO PAGECOUNT\r\n\@PJL RDYMSG DISPLAY = \"test 2 3 4\"\033%-12345X\r\n");
87 sendpjlcommand($SOCKET, 'RDYMSG DISPLAY = "'.$nonsensemessages[rand(@nonsensemessages)].'"', 3);