Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
bash我想在or中将 Python 解释器作为劣质进程运行zsh。在此期间,我想向进程发送命令并查看STDOUT. 像这样的东西:
bash
zsh
STDOUT
$ in=/dev/shm/python_test_in $ out=/dev/shm/python_test_out $ touch $in $out $ python < $in > $out $ echo print(1+1) > $in $ cat $out
可悲的是,这不起作用。我正在运行 GNU/Linux。
你需要的是一个管道:
mkfifo ./in ./out python < ./in > ./out & echo "print(1+1)" > ./in cat ./out
但是,通过这种方式,python 解释器将在执行后立即退出,因为它在“echo”行中读取了 EOF。我正在寻找防止python解释器在EOF上退出的方法。