[IPython-User] catching system call's output in notebook
Mon Feb 6 13:22:20 CST 2012
On 6 February 2012 19:15, Julian Taylor <firstname.lastname@example.org>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:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-User