如何使用子进程在konsole中启动尾部

时间:2016-06-28 09:04:22

标签: python subprocess tail

我使用tail从解算器输出列表:

outputListing = exportFileName.split(".pc")[0] + ".out" 
solver_run = subprocess.Popen([solver_path, "-visual", "-solvargs", "-nt 4 -fp 2", exportFilePath, outputListing])
if os.sep == "\\":
    subprocess.Popen(["wintail",outputListing], shell = True)
elif os.sep == "/":
    if os.environ.get("DESKTOP_SESSION") == 'gnome'
        subprocess.Popen(["gnome-terminal", "-e","tail -f " + outputListing])
    elif os.environ.get("DESKTOP_SESSION") == 'kde'
        subprocess.Popen(["konsole", "-e","tail -f " + outputListing])

通过此调用,解算器列表在GNOME中输出,但在KDE中仅启动了唯一的终端(konsole),但没有执行尾部。所以我可能需要更换" -e"和" tail -f"因此。对于正确的电话有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我自己找到了解决方案。必须使用:

subprocess.Popen(["konsole", "-e","$SHELL", "-c","tail -f " + outputListing])

所以关键是在电话中添加“$ SHELL”和“-c”