Execute Command and write in variable

Alex Martelli aleaxit at yahoo.com
Fri Oct 29 09:47:27 EDT 2004


tobias <tobias at topi.homelinux.org> wrote:

> Hello
> 
> How can I execute a command (like "uptime") in python, and write the 
> output into a variable?

import os

avariable = os.popen('uptime').read()


Alex



More information about the Python-list mailing list