在html页面上显示命令行输出 [英] Showing command line output on a html page

查看:68
本文介绍了在html页面上显示命令行输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个Web应用程序,该程序在终端上运行某些命令,并将结果显示回Web应用程序.我能够使用child_process.exec运行命令,并在html页面上显示它时获取我所面临的问题的结果.

I am building a web app which runs certain commands on the terminal and display the results back on web app. I am able to run commands using child_process.exec and fetch the results the problem i'm facing is while displaying it on an html page.

我想要这样的东西:

有没有办法显示这样的命令行输出?任何线索都可以.谢谢.

Is there any way to show the command line output like this ? Any leads would do. Thank you.

推荐答案

要在浏览器或Web应用程序中获得类似终端/外壳/控制台的体验,请查看...

For a terminal/shell/console-like experience in a browser or web app, check out...

JS解决方案,用于交互

  • https://xtermjs.org
  • https://github.com/chjj/tty.js
  • http://sdether.github.io/josh.js
  • https://terminal.jcubic.pl/
  • https://github.com/liftoff/GateOne
  • https://github.com/1j01/simple-console
  • https://www.masswerk.at/termlib/index.html

仅HTML/CSS的解决方案,用于非交互性

这些只是模拟一个终端,而不是真正连接到外壳

These are just simulating a terminal, not really beeing connected to a shell

或者从头开始使用黑色背景,白色等宽字体并从那里开始构建...

Or perhaps start from scratch with a black background, white mono-space font and build it up from there...

CodePen

#container {
  background-color: #000000;
  width: 100%;
  height: 100%;
  max-width: 400px;
  max-height: 400px;
  padding: 3em;
}

#content {
  color: #ffffff;
  font-size: 16px;
  font-family: monospace;
}

<div id="container">
  <div id="content">
    <p>Hello world</p>
    <p>Hello world</p>
    <p>Hello world</p>
    <p>Hello world</p>
  </div>
</div>

这篇关于在html页面上显示命令行输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆