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

 

posted @ 2019-08-03 00:47  papering  阅读(455)  评论(0编辑  收藏  举报