yixin026

一个很绕的通过程序来控制各种 shell 的办法

  •  
  •   yixin026 · Jul 28, 2022 · 2061 views
    This topic created in 1384 days ago, the information mentioned may be changed or developed.

    公司有个设备,只提供了一个用 python 改的 shell.没有任何其他的接口,现在有些也要需要通过命令行即时的交互计算,然后找了好久没找到通过程序来控制这些的方法..最后想到了用 tmux 先绕过去

    1.开一个 tmux 的 session,在里面打开 shell tmux new-session -s development 2.通过 tmux send-keys 发命令,比如 tmux send-keys -t development 'python' C-m 3.通过 tmux capture-pane 获取 session 里的屏幕输出 tmux capture-pane -t development -p -S -100 -E- 这样输入输出就都有了,勉强可以凑合着用了

    2 replies    2022-07-29 09:32:25 +08:00
    haoliang
        1
    haoliang  
       Jul 28, 2022
    看着挺绕的,这样如何?

    tmux pane 1: python &>/tmp/xx (依情况看是否需要 mkfifo /tmp/xx 、是否需要分开 stderr 、stdout )
    tmux pane 2: tail -f /tmp/xx
    这么看来不用 tmux , 开两个终端也行
    yixin026
        2
    yixin026  
    OP
       Jul 29, 2022
    @haoliang 没有 tmux 的话感觉命令的输入会有问题..试过好多方法这种 shell 貌似基本没什么简单的办法输入命令...读日志的话这样确实可以,但是用 tmux 的话可以自动清除历史..
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5898 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 02:38 · PVG 10:38 · LAX 19:38 · JFK 22:38
    ♥ Do have faith in what you're doing.