Yaakov wrote a sweet little Perl script to change the default message on HP printers. Here is the ruby version of this script, which I saved as hpset.rb:
#!/usr/local/bin/ruby
if ARGV.size != 2
puts "Usage: #{$0} [printer_ip_address] \"message\""
puts "Note: don't forget the quotes around your message"
exit
end
hpcommand = <<EOF
\e%-12345X\@PJL JOB"
\@PJL RDYMSG DISPLAY="#{ARGV[1]}"
\@PJL EOJ
\e%-12345X
EOF
require 'socket'
include Socket::Constants
socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
sockaddr = Socket.pack_sockaddr_in( 9100, ARGV[0] )
socket.connect( sockaddr )
socket.write( hpcommand )
socket.close
This thing is a blast. If there is any interest I'll post funny message ideas on this blog from time to time.
0 comments:
Post a Comment