Storing Subprocess Results

Benjamin Kaplan benjamin.kaplan at case.edu
Tue Sep 2 10:35:12 EDT 2008


On Tue, Sep 2, 2008 at 10:16 AM, topazcode <ter at topazcode.com> wrote:

> I am using the subprocess module to run some shell commands on a Linux
> system:
>
> import subprocess
> output = subprocess.call('''ssh server1 "uptime"''', shell=True)
>
> The above assigns the output variable with a return code, i.e. 0 in
> this case.  How can I actually capture the data returned from
> subprocess.call, rather than just the return code?  I'd like to have
> the output variable contain the uptime string in this case.  Any help
> is appreciated.  Thanks.
> --
> http://mail.python.org/mailman/listinfo/python-list
>


http://docs.python.org/lib/node532.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080902/082fa2e3/attachment-0001.html>


More information about the Python-list mailing list