Running a secondary script in a new terminal

前端 未结 3 1217
暖寄归人
暖寄归人 2021-01-23 03:54

When running a secondary python script:

  • Is it possible to run a subprocess.Popen, or subprocess.call or even execfile in a n
3条回答
  •  死守一世寂寞
    2021-01-23 04:18

    I guess you want something like

    subprocess.call(['xterm','-e','python',script])
    

    Good old xterm has almost no frills; on a Freedesktop system, maybe run xdg-terminal instead. On Debian, try x-terminal-emulator.

    However, making your program require X11 is in most cases a mistake. A better solution is to run the subprocesses with output to a log file (or a socket, or whatever) and then separately run tail -f on those files (in a different terminal, or from a different server over ssh, or with output to a logger which supports rsyslog, or or or ...) which keeps your program simple and modular, free from "convenience" dependencies.

提交回复
热议问题