def run_command ( cmd , * args ) : command = ' ' . join ( ( cmd , args ) ) p = Popen ( command , shell = True , stdout = PIPE , stderr = PIPE ) stdout , stderr = p . communicate ( ) return p . retcode , stdout , stderr
how to execute shell commmands in python and return output
Runs command on the system with given args .
def run_command(cmd, *args):
    """
    Runs command on the system with given ``args``.
    """
    command = ' '.join((cmd, args))
    p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)
    stdout, stderr = p.communicate()
    return p.retcode, stdout, stderr