Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [matt] /tmp $ python
- Python 2.6.6 (r266:84374, Aug 31 2010, 11:00:51)
- [GCC 4.0.1 (Apple Inc. build 5493)] on darwin
- Type "help", "copyright", "credits" or "license" for more information.
- >>> from subprocess import Popen, PIPE
- >>>
- >>> f = open('dafile', 'w')
- >>> f.write('import sys\n'
- ... 'raise Exception("hey")')
- >>> f.close()
- >>>
- >>> p = Popen(['python', 'dafile'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
- >>> stdout, stderr = p.communicate('foo')
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 691, in communicate
- return self._communicate(input)
- File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1222, in _communicate
- bytes_written = os.write(self.stdin.fileno(), chunk)
- OSError: [Errno 32] Broken pipe
- >>>
- [matt] /tmp $ python
- Python 2.6.6 (r266:84374, Aug 31 2010, 11:00:51)
- [GCC 4.0.1 (Apple Inc. build 5493)] on darwin
- Type "help", "copyright", "credits" or "license" for more information.
- >>> from subprocess import Popen, PIPE
- >>>
- >>> f = open('dafile', 'w')
- >>> f.write('import sys\n'
- ... 'raise Exception("hey")')
- >>> f.close()
- >>>
- >>> p = Popen(['python', 'dafile'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
- >>> stdout, stderr = p.communicate('foo')
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 691, in communicate
- return self._communicate(input)
- File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1222, in _communicate
- bytes_written = os.write(self.stdin.fileno(), chunk)
- OSError: [Errno 32] Broken pipe
- >>>
Add Comment
Please, Sign In to add comment