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 Mem: 3880404 988888 118752 25140 2772764 2561112 Swap: 0 0 0 ', 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 nohup.out npm-debug.log pkgTmp ', 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 nohup.out npm-debug.log pkgTmp ' >>> output = subprocess.Popen(['tree','./pkgTmp/'],stdout=subprocess.PIPE,shell=True).communicate() >>> output[0] b'. xe2x94x9cxe2x94x80xe2x94x80 config.json xe2x94x9cxe2x94x80xe2x94x80 nohup.out xe2x94x9cxe2x94x80xe2x94x80 npm-debug.log xe2x94x94xe2x94x80xe2x94x80 pkgTmp xe2x94x9cxe2x94x80xe2x94x80 mysql57-community-release-el7-10.noarch.rpm xe2x94x94xe2x94x80xe2x94x80 Python-3.7.4.tgz 1 directory, 5 files ' >>> output[0].decode('utf-8') '. ├── config.json ├── nohup.out ├── npm-debug.log └── pkgTmp ├── mysql57-community-release-el7-10.noarch.rpm └── Python-3.7.4.tgz 1 directory, 5 files ' >>> [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