- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试从同一个 Python 脚本(很像 this fellow )在两个终端中输出不同的信息。我的研究似乎指出的方法是使用 subprocess.Popen 打开一个新的 xterm 窗口并运行 cat 以在窗口中显示终端的标准输入。然后我会像这样将必要的信息写入子进程的标准输入:
from subprocess import Popen, PIPE
terminal = Popen(['xterm', '-e', 'cat'], stdin=PIPE) #Or cat > /dev/null
terminal.stdin.write("Information".encode())
然后字符串“Information”将显示在新的 xterm 中。然而,这种情况并非如此。 xterm 不显示任何内容,而 stdin.write 方法只是返回字符串的长度,然后继续。我不确定子流程和管道的工作方式是否存在误解,但如果有人能帮助我,我将不胜感激。谢谢。
最佳答案
这是行不通的,因为您将内容传送到 xterm
本身,而不是在 xterm
中运行的程序。考虑使用命名管道:
import os
from subprocess import Popen, PIPE
import time
PIPE_PATH = "/tmp/my_pipe"
if not os.path.exists(PIPE_PATH):
os.mkfifo(PIPE_PATH)
Popen(['xterm', '-e', 'tail -f %s' % PIPE_PATH])
for _ in range(5):
with open(PIPE_PATH, "w") as p:
p.write("Hello world!\n")
time.sleep(1)
关于python - 使用 Python 的子进程在新的 Xterm 窗口中显示输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5558720/
在对 Xterm 进行了大量研究之后,仔细研究了我已经认输的大量网页,并意识到这不是我自己可以解决的问题。 TrueType 与位图 是选项xterm*font用于仅指定位图字体并且是 *faceNa
我如何向 XTerm 终端发出输入结束信号。在我的例子中,我在 XTerm 控制台中运行一个 C++ 程序,我想通过按下一些键盘按钮组合来向程序发出输入结束信号。(我试过 Ctrl+D Ctrl+Z
我正在尝试 automate xterm它主要依赖于启动xterm时的-S选项。 来自手册页 -Sccn This option allows xterm to be used as an input
我的应用程序尝试执行根命令“sudo ifup eth0”和“sudo ifdown eth0”。但是它返回了一个错误“sudo:抱歉,你必须有一个 tty 才能运行 sudo”。因此,它需要一个 t
我有字体(由 fc-list 列出): /usr/share/fonts/misc/Inconsolata-dz for Powerline.otf: Inconsolata\-dz for Powe
我尝试在Reactjs中使用Xtermjs。但当我按照指南进行操作时。结果如下: 它应该显示没有顶部文本区域和文本“W”。 我的代码如下: import React from 'react'; imp
在尝试将我的终端程序设置为使用颜色时,我遇到了 xterm-color 和 xterm-256color 作为选项 - 即您可以设置您的 TERM 环境变量中的任何一个。 我想知道是否有人可以描述两者
我有一个 python 程序 (mypro.py),我想在其中同时在拓扑的所有主机上运行(即,无需转到每个 xtrem 窗口并键入 python mypro .py)。有没有办法通过使用脚本在 Min
不,不是 ASCII 图形,请参见此处的屏幕截图: http://en.wikipedia.org/wiki/W3m 这怎么可能? 我检查了源代码,它只打印字符序列。但是,我无法在 xterm 文档或
我想知道如何通过 execl 调用 Xterm。例如,对于下面的代码 #include #include #include #include #include #include #incl
我需要编写一个 bash 脚本,它会生成一个新的 xterm 窗口并在那边回显一些内容。我试过 echo "hello"| xterm &,它不起作用...此外,是否可以在新的 xterm 上执行任何
如果我像这样用 xterm 调用一个命令(在我的例子中是另一个脚本): xterm -e sh second.sh xterm 返回后$? 中的值是xterm 的退出状态码(通常对我来说是0)而不是我
我正在尝试为文件夹集合中的每个实例运行客户端和服务器。我试过这个命令: $ find ./-name "Makefile"-execdir xterm -title "Server"-e "timeo
我想在 C++ 中运行 xterm 终端来创建这样一个 Linux 进程 system("xterm -e adb start-server") adb 进程已创建,但在执行该命令后它会被终止。我试图
我安装了一个最小的 debian,我试图自己设置一切,所以我试图通过给它一些颜色来调整我的默认终端 Xterm,经过一些研究我发现这可以通过编辑.Xresources 文件,所以我可以用 Hexa 代
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎偏离主题,因为它缺乏足够的信息来诊断问题。 更详细地描述您的问题或 include a mini
如果在 linux 上使用子进程执行一个 xterm,而 xterm 又执行一些其他进程,Python (2.6.5) 似乎永远不会识别进程 (xterm) 已完成执行。 考虑以下代码: import
我正在编写一个打印彩色线条的程序,我用它做的越多,我就越发现自己在解决出现的换行问题。 这是一种用php编写的终端,这里是提示符: $return = readline("\033[44m\033[1
我正在使用 virtualenv(它设置了一些环境变量)。现在,我想生成一个具有相同环境的新终端窗口。如果我尝试: xterm & 我得到了一个新终端但是环境是默认环境,也就是当我在新终端上输入以下行
我经常使用 less 查看文件,并且想记住我刚刚在文件中看到的内容。但是,当我通过按 q 键退出 less 时,我的 xterm 窗口删除了 less 显示文件的页面,只显示我的命令提示符。 如何在退
我是一名优秀的程序员,十分优秀!