Python executes Linux shell commands and returns the results as a list

 Python executes Linux shell commands and returns the results as a list

import os

def execShellCmd(cmd):
    f = os.popen(cmd)
    if f:
        data = f.readlines()
        f.close()
        return data
    else:
        return []

Comments

Popular posts from this blog

Python Receiving and parse JSON Data via UDP protocol

ubus lua client method and event registration code demo/example