【问题标题】:How to start tail in konsole with subprocess如何使用子进程在 konsole 中启动 tail
【发布时间】:2016-06-28 09:04:22
【问题描述】:

我正在使用 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”。任何关于正确通话的想法?

【问题讨论】:

    标签: python subprocess tail


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2014-02-02
      • 1970-01-01
      • 2012-02-27
      • 2011-11-24
      • 2017-08-01
      • 1970-01-01
      • 2018-02-04
      • 2014-06-25
      • 1970-01-01
      相关资源
      最近更新 更多