web-linux-shell实现 阿里方案canvas+wss。
wss://shell.aliyun.com/terminals?cols=92&rows=35
[root@webshell ~]# python
Python 3.6.8 (default, Apr 25 2019, 21:02:35)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> output = subprocess.Popen(['ls','-l'],stdout=subprocess.PIPE,shell=True).communicate()
>>> output = subprocess.Popen(['free ','-g'],stdout=subprocess.PIPE,shell=True).communicate()
>>> output
(b' total used free shared buff/cache available\nMem: 3880404 988888 118752 25140 2772764 2561112\nSwap: 0 0 0\n', None)
>>> output = subprocess.Popen(['tree /'],stdout=subprocess.PIPE,shell=True).communicate()
^CTraceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.6/subprocess.py", line 850, in communicate
stdout = self.stdout.read()
KeyboardInterrupt
>>>
KeyboardInterrupt
>>>
KeyboardInterrupt
>>> output = subprocess.Popen(['top'],stdout=subprocess.PIPE,shell=True).communicate()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python3.6/subprocess.py", line 850, in communicate
stdout = self.stdout.read()
KeyboardInterrupt
>>>
KeyboardInterrupt
>>> output = subprocess.Popen(['ls'],stdout=subprocess.PIPE,shell=True).communicate()
>>> output
(b'config.json\nnohup.out\nnpm-debug.log\npkgTmp\n', None)
>>> output = subprocess.Popen(['ll'],stdout=subprocess.PIPE,shell=True).communicate()
/bin/sh: ll: command not found
>>> output = subprocess.Popen(['ls','-l'],stdout=subprocess.PIPE,shell=True).communicate()
>>> output[0]
b'config.json\nnohup.out\nnpm-debug.log\npkgTmp\n'
>>> output = subprocess.Popen(['tree','./pkgTmp/'],stdout=subprocess.PIPE,shell=True).communicate()
>>> output[0]
b'.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 config.json\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 nohup.out\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 npm-debug.log\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 pkgTmp\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 mysql57-community-release-el7-10.noarch.rpm\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 Python-3.7.4.tgz\n\n1 directory, 5 files\n'
>>> output[0].decode('utf-8')
'.\n├── config.json\n├── nohup.out\n├── npm-debug.log\n└── pkgTmp\n ├── mysql57-community-release-el7-10.noarch.rpm\n └── Python-3.7.4.tgz\n\n1 directory, 5 files\n'
>>> [root@webshell ~]# tree ./pkgTmp/
./pkgTmp/
├── mysql57-community-release-el7-10.noarch.rpm
└── Python-3.7.4.tgz 0 directories, 2 files
[root@webshell ~]#
https://www.cnblogs.com/snow-backup/p/5035792.html
web-linux-shell实现 阿里方案canvas+wss。的更多相关文章
- 阿里Linux Shell脚本面试25个经典问答
转载: 阿里Linux Shell脚本面试25个经典问答 Q:1 Shell脚本是什么.它是必需的吗? 答:一个Shell脚本是一个文本文件,包含一个或多个命令.作为系统管理员,我们经常需要使用多个命 ...
- Linux云主机 监控方案浅析
1.为何需要监控 监控是运维工程师的眼睛,它可帮助运维工程师第一时间发现系统的问题. 对于服务器的整个生命周期,都要和监控打交道: 当有服务器上架,都需要加入比如CPU负载.内存.网络.磁盘等基础监控 ...
- Linux Shell脚本攻略 读书笔记
Linux Shell脚本攻略 读书笔记 这是一本小书,总共253页,但内容却很丰富,书中的示例小巧而实用,对我这样总是在shell门前徘徊的人来说真是如获至宝:最有价值的当属文本处理,对这块我单独整 ...
- Linux Shell脚本教程
v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VM ...
- 【转】Awk 命令学习总结、AWk命令系列学习(linux shell)
前面的话 学习linux 的同人,都知道linux shell文本处理能力非常强大.有一组强大的文本处理工具:grep,sed,awk . 其中grep 经常用作查找匹配文本.sed用作文本编辑替换. ...
- 读《Linux Shell脚本攻略》(第2版) 总结
前段时间读完了<Linux Shell脚本攻略>(第2版)这本书,给部分想读这本书的人分享下个人感受. 说下这本书的难度吧.纯新手或者只懂少部分编程知识的人,读起来还是有很大难度的.以我为 ...
- laravel项目使用appnode部署linux系统到阿里云服务器流程记录(待补充)
使用 SSH 连接工具,如 PuTTY.XShell.SecureCRT 等,连接 Linux 服务器后(阿里云服务器命令行内直接输入appnode安装命令,版本:mysql选5.7.php选7.2) ...
- 读《Linux Shell脚本攻略》(第2版) 一遍、二遍体会
前段时间读完了<Linux Shell脚本攻略>(第2版)这本书,给部分想读这本书的人分享下个人感受. 第一遍体会解读:就像黑夜中的灯塔,指明前进的道路. 推荐指数:强烈推荐. 书中讲解的 ...
- Awk 命令学习总结、AWk命令系列学习(linux shell)
AWK基本语法 下面没有提到awk命令怎么使用了,你可以通过 运行:awk –h 查询到所有命令及参数!下面把awk作为一门语言分节介绍. linux awk 内置变量使用介绍 awk语言中,怎么 ...
随机推荐
- pip 和pip3的区别
前言装完python3后发现库里面既有pip也有pip3,不知道它们的区别,因此特意去了解了一下. 解释先搜索了一下看到了如下的解释, 安装了python3之后,库里面既会有pip3也会有pip 1. ...
- keepalived,tomcat,memcache
1.Nginx+Keepalived实现站点高可用 linux cluster类型 LB:nginx负载,varnish(director module)haproxy,lvs HA:keepaliv ...
- Linux命令——modprobe
参考:5 UNIX / Linux modprobe Command Examples Linux modprobe command 简介 modprobe用于向Linux Kernel添加 或 移除 ...
- 搭建MySQL MMM高可用
搭建MMM: 1,安装 agent 节点执行 yum install -y mysql-mmm-agent 2, monitor 节点执行 yum install -y mysql-mmm-monit ...
- WebSocketServer
@Component @ServerEndpoint(value = "/endpoint/ws") public class WebSocketServer { private ...
- linux的vim基本使用
转自:https://www.cnblogs.com/qq631243523/p/10191714.html 所有的 Unix Like 系统都会内建 vi 文书编辑器,其他的文书编辑器则不一定会存在 ...
- 十四.Protobuf3扩展
在您发布使用Protocol Buffer区的代码后,您迟早会因为业务需求变更想要“改进”Protocol Buffer的定义.如果你想让你的新Protocol Buffer向后兼容,让你的旧Prot ...
- C#调用一下CMD
C#程序调用CMD执行命令 在windows环境下,命令行程序为cmd.exe,是一个32位的命令行程序,微软Windows系统基于Windows上的命令解释程序,类似于微软的DOS操作系统.输入 ...
- spring+mybatis通用dao层、service层的实现
个人理解: 1.mybatis-spring.jar 提供了SqlSessionTemplate类该类可以对数据库进行CRUD操作(底层其实还是SqlSession) 2.我们可以集成SqlSessi ...
- HttpMessageConverter(消息转换器 )和@responsebody使用(转)
@responsebody表示该方法的返回结果直接写入HTTP response body中 一般在异步获取数据时使用,在使用@RequestMapping后,返回值通常解析为跳转路径,加上@resp ...