Skip to content

Instantly share code, notes, and snippets.

@joshuashaffer
Created May 18, 2016 21:29
Show Gist options
  • Save joshuashaffer/e62d77516acdc1b7ad92cb5e28265002 to your computer and use it in GitHub Desktop.
Save joshuashaffer/e62d77516acdc1b7ad92cb5e28265002 to your computer and use it in GitHub Desktop.
My linux printing solution...
#! /usr/bin/env python
import sys,os,subprocess
import climate
def printer(filename,printer_ip= "192.168.0.50"):
_rc0 = _rcr1, _rcw1 = os.pipe()
if os.fork():
os.close(_rcw1)
os.dup2(_rcr1, 0)
subprocess.call(["nc",printer_ip,"9100"],shell=False)
else:
os.close(_rcr1)
os.dup2(_rcw1, 1)
subprocess.call(["gs","-sDEVICE=ljet4","-q","-dNOPAUSE","-dSAFER","-sOutputFile=-",str(sys.argv[1]),"-c","quit"],shell=False)
sys.exit(0)
if __name__ == '__main__':
climate.call(printer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment