V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
ithelloworld
V2EX  ›  程序员

如何以Web的形式实时显示terminal中的内容?

  •  
  •   ithelloworld · 2013-03-07 10:35:51 +08:00 · 4593 次点击
    这是一个创建于 4074 天前的主题,其中的信息可能已经有所发展或是发生改变。
    执行一段脚本,可以在terminal中看打印输出结果。
    如果想在网页,浏览器中检视此事,能不能办到?
    就像Ubuntu软件安装一样,安装界面点击“详细”可看到执行的详细安装信息。
    11 条回复    1970-01-01 08:00:00 +08:00
    ratazzi
        1
    ratazzi  
       2013-03-07 10:45:11 +08:00   ❤️ 1
    python 的话用 subprocess.Popen 调用脚本,再通过 websocket 一类的将标准输出输出到浏览器
    luztak
        2
    luztak  
       2013-03-07 10:54:51 +08:00 via Android
    运行一个shell,把socket的io设置成stdin/stdout.
    这个在Windows上能用,Linux没测试.
    从某本书上看的.
    amoblin
        3
    amoblin  
       2013-03-07 11:18:41 +08:00
    ithelloworld
        4
    ithelloworld  
    OP
       2013-03-07 12:30:08 +08:00
    @amoblin 这个支持的命令好像不多呀
    amoblin
        5
    amoblin  
       2013-03-07 12:31:32 +08:00
    @ithelloworld 大致看了下,没细研究。如果不要求实时的话,可以用一下Marboo Shell: http://marboo.biz/guide/#marboo-shell
    ericFork
        6
    ericFork  
       2013-03-07 13:19:08 +08:00
    @ratazzi +1, 我们就是这么做的
    zodiac1111
        7
    zodiac1111  
       2013-03-07 18:42:40 +08:00
    我知道有用shellinabox的(比如落云).看看是不是你的需要.
    darasion
        8
    darasion  
       2013-03-07 18:47:42 +08:00   ❤️ 1
    wangkangluo1
        9
    wangkangluo1  
       2013-03-08 13:47:30 +08:00
    wangkangluo1
        10
    wangkangluo1  
       2013-03-08 13:49:42 +08:00
    @wangkangluo1 长期使用shellinbox,其他有
    Ajaxterm
    Anyterm
    Commando.io
    Gate One
    WebShell
    tty.js
    但推荐shellinbox.
    BOYPT
        11
    BOYPT  
       2013-03-08 15:24:01 +08:00
    如果要只看不输入的话也没什么困难的,Popen stdout喂queue,web线程消费queue,ajax定时刷新这个接口,append到DOM就是了。

    为了避免内存泄漏什么的,当然最好用环队列。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2228 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 04:15 · PVG 12:15 · LAX 21:15 · JFK 00:15
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.