Guest User

Untitled

a guest
Sep 13th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #! /usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3.  
  4. import subprocess
  5.  
  6. # why is this not executed immediately?
  7. lpr = subprocess.Popen("/usr/bin/lpr", # on raspbian: /usr/bin/lp
  8. stdin=subprocess.PIPE,
  9. stdout=subprocess.DEVNULL, # proposed by user elias
  10. close_fds=True) # proposed by user elias
  11.  
  12. output = "Username: testusern".encode()
  13. + "Password: p4ssw0rdn".encode()
  14.  
  15. lpr.stdin.write(output)
  16.  
  17. while True:
  18. pass
  19.  
  20. #! /usr/bin/env python3
  21. # -*- coding: utf-8 -*-
  22.  
  23. import subprocess
  24. import time
  25.  
  26. # why is this not executed immediately?
  27. lpr = subprocess.Popen("/usr/bin/lpr", # on raspbian: /usr/bin/lp
  28. stdin=subprocess.PIPE,
  29. stdout=subprocess.DEVNULL, # proposed by user elias
  30. close_fds=True) # proposed by user elias
  31.  
  32. output = "Username: testusern".encode()
  33. + "Password: p4ssw0rdn".encode()
  34.  
  35. lpr.stdin.write(output)
  36.  
  37. time.sleep(20)
Add Comment
Please, Sign In to add comment