-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprinter.rb
executable file
·63 lines (31 loc) · 885 Bytes
/
printer.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env ruby
# Simple HP Printer Hacker
# Written in Ruby by Erik Gregg
# 6/9/06
# Status Usage: hp-message.rb <host> status
# Message Usage: hp-message.rb <host> message "<message>"
require 'net/telnet'
begin
if ARGV[0].nil?
puts "Read the script.
Status Usage: hp-message.rb <host> status
Message Usage: hp-message.rb <host> message \"<message>\""
exit
end
host = Net::Telnet::new("Host" => ARGV[0],
"Port" => 9100,
"Timeout" => 5,
"Prompt" => /\b/n)
if ARGV[1] == "status"
host.cmd("@PJL INFO STATUS") { |c| print c }
elsif ARGV[1] == "message"
host.cmd("@PJL RDYMSG DISPLAY=\""+ARGV[2]+"\"")
else
puts "Oh Cmon. Look at the syntax inside me."
exit
end
host.close
rescue Timeout::Error
puts "Time to go now!"
exit 1
end