[IPython-User] catching system call's output in notebook

Zoltán Vörös zvoros@gmail....
Mon Feb 6 13:29:37 CST 2012

Julian and Thomas,

Thanks for the comments!

On 02/06/2012 08:22 PM, Thomas Kluyver wrote:
> On 6 February 2012 19:15, Julian Taylor <jtaylor.debian@googlemail.com 
> <mailto:jtaylor.debian@googlemail.com>> wrote:
>     use the subprocess module instead of os.system:
>     import subprocess
>     print subprocess.check_output(["./test"])
> To explain some more about the difference: when you do os.system, it's 
> not capturing stdout/stderr from the new process. In the terminal, 
> this works, because stdout and stderr just go directly to the 
> terminal, without Python ever knowing about them. In the notebook, it 
> doesn't, because the kernel can only forward stdout/stderr that it 
> knows about.
> subprocess.check_output() captures stdout and returns it. If you need 
> to capture stderr as well, refer to the docs: 
> http://docs.python.org/library/subprocess#subprocess.check_output
> Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20120206/069fa165/attachment.html 

More information about the IPython-User mailing list