python包装器执行两个命令

时间:2018-10-24 10:51:07

标签: python

我正在尝试在远程服务器上使用python运行两个命令。虽然 函数main()执行,仅执行第一个命令,第二个不执行。有人可以帮我吗?

#!/usr/bin/python

import sys
import shlex, subprocess

sut = sys.argv[1]
pp = sys.argv[2]
sut_adapter = sys.argv[3]
pp_adapter = sys.argv[4]
switch_ip = sys.argv[5]
switch = sys.argv[6]
node_type = sys.argv[7]
hmc_name = sys.argv[8]

filename = sys.argv[1] + "_" + sys.argv[2] + ".p.config"

args_str= "/home/raymond/config_gen.pl {} {} {} {} {} {} {} {}".format(sut, pp, sut_adapter, pp_adapter, switch_ip, switch, node_type, hmc_name)
args_str2 = "/framework/scripts/ts//ts /home/NDD/fvndd_dedicated.p -t standard_frames_dedicated -c 1 -g /Jenkins/config/{}".format(filename)

def test_run():

        args2 = shlex.split(args_str2)
        pipe = subprocess.Popen(args2,bufsize=-1,stdin=subprocess.PIPE)


def main():

        args = shlex.split(args_str)
        pipe = subprocess.Popen(args,bufsize=-1,stdin=subprocess.PIPE)

        test_run()

if __name__== "__main__":
        main()

0 个答案:

没有答案