Guest User

Untitled

a guest
Aug 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. [matt] /tmp $ python
  2. Python 2.6.6 (r266:84374, Aug 31 2010, 11:00:51)
  3. [GCC 4.0.1 (Apple Inc. build 5493)] on darwin
  4. Type "help", "copyright", "credits" or "license" for more information.
  5. >>> from subprocess import Popen, PIPE
  6. >>>
  7. >>> f = open('dafile', 'w')
  8. >>> f.write('import sys\n'
  9. ... 'raise Exception("hey")')
  10. >>> f.close()
  11. >>>
  12. >>> p = Popen(['python', 'dafile'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
  13. >>> stdout, stderr = p.communicate('foo')
  14. Traceback (most recent call last):
  15. File "<stdin>", line 1, in <module>
  16. File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 691, in communicate
  17. return self._communicate(input)
  18. File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1222, in _communicate
  19. bytes_written = os.write(self.stdin.fileno(), chunk)
  20. OSError: [Errno 32] Broken pipe
  21. >>>
  22. [matt] /tmp $ python
  23. Python 2.6.6 (r266:84374, Aug 31 2010, 11:00:51)
  24. [GCC 4.0.1 (Apple Inc. build 5493)] on darwin
  25. Type "help", "copyright", "credits" or "license" for more information.
  26. >>> from subprocess import Popen, PIPE
  27. >>>
  28. >>> f = open('dafile', 'w')
  29. >>> f.write('import sys\n'
  30. ... 'raise Exception("hey")')
  31. >>> f.close()
  32. >>>
  33. >>> p = Popen(['python', 'dafile'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
  34. >>> stdout, stderr = p.communicate('foo')
  35. Traceback (most recent call last):
  36. File "<stdin>", line 1, in <module>
  37. File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 691, in communicate
  38. return self._communicate(input)
  39. File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1222, in _communicate
  40. bytes_written = os.write(self.stdin.fileno(), chunk)
  41. OSError: [Errno 32] Broken pipe
  42. >>>
Add Comment
Please, Sign In to add comment