如何让python脚本同时运行sh和csh脚本?

时间:2018-06-17 02:00:34

标签: python python-2.7 shell

我有一个像这样的csh文件:

#!/bin/csh
setenv ...
setenv ...
some_command ...

我需要执行2-3次。

然后我还需要能够执行以下内容:

cd ...
some_command ...

我已经有了这段代码:

def run_commands(command_line):


    args = shlex.split(command_line)
    make_process = subprocess.Popen(args, stderr = subprocess.STDOUT, shell=True)
    output, error = make_process.communicate()

    if make_process.returncode != 0:
        makefile_error(command_line)
    else:   
        print "The command " + command_line + " executed without errors."


    return

这实际上在几天前有效,现在突然间它给了我这个错误:

line 0: source: filename argument required source: usage: source filename [arguments]Error occured with the source mycshfile.csh command

如何在一个流程中执行两种类型的命令?

0 个答案:

没有答案