from subprocess import check_output as co
import os
"""
本脚本仅用于测试通过python调用bat脚本的功能
要求调用bat脚本后，bat的进程在后台要存在
比如bat脚本的title为‘test’，那么后台进程中应该有image为cmd.exe，title为test的进程存在
"""

def bash_cmd(cmd):
    try:
        cmd = cmd + " 2>/dev/null"
        a = co(['bash', '-c', cmd]).decode('utf8')
        return a
    except Exception:
        print('%s: command not found' % cmd)
        return False


bat_file = "start cmd /k C:/Users/EDY/Desktop/monitor/dist/start.bat"
os.system(bat_file)

# print(bash_cmd('cd /etc/ ; ls ; cd / ;ls'))
# print(bash_cmd('ps -ef'))
