python 'hphack' - change display of HP printer
Jeff
jam at quark.emich.edu
Fri Jul 21 20:16:00 EDT 2000
greetings,
here's a (very) quick script I wrote based on code posted to freshmeat
(http://freshmeat.net/appindex/2000/06/22/961716715.html)
all it does is change the display of an HP laserjet printer from "Ready" to
16 characters of your choosing. it shows the basics of socket calls in
python (vs. the C version), and is very short.
if anyone has suggestions as to how the code could be improved, please mail
them to me directly or post to the list.
I hereby release this version of the code as GPL.
-- begin --
#!/usr/bin/env python
import sys
import getopt
import socket
_RCSID = "$Id: hphack.py,v 1.1 2000/06/25 13:36:59 jam Exp $"
# http://cssweb.nectech.com/printers/pclcodes/pcl5hp.htm
# http://freshmeat.net/appindex/2000/06/22/961716715.html
UEL = chr(0x1B)+chr(0x25)+chr(0x2D)+chr(0x31)+chr(0x32)+chr(0x33)+chr(0x34)+chr(0x35)+chr(0x58)
def help():
pass
def version():
print _RCSID
def main():
opts, sopts = getopt.getopt(sys.argv[1:], "", [ "help", "version" ])
for n, v in opts:
if n == "--help":
help()
return
elif n == "--version":
version()
return
if len(sopts) != 2:
print "takes two parameters: ipaddress and message."
return
dest = sopts[0]
message = sopts[1]
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(dest, 9100)
buf = UEL + '@PJL RDYMSG DISPLAY = "%s"\n' % (message) + UEL + "\n"
s.send(buf)
s.close()
if __name__ == "__main__":
main()
-- end --
regards,
J
--
|| visit gfd <http://quark.emich.edu/>
|| psa member -- <http://www.python.org/psa/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20000721/a808f7a2/attachment.sig>
More information about the Python-list
mailing list