The official documentation has a phrase "allows you to call any program" and:
Helps you write shell scripts In python by giving you the good features of bash first sentence to help you easily call your own program in Python, the second sentence gives you the opportunity and Shell This local tyrants make Friends ㈠ call System program [Python] >>> import sh >>> print (sh.ls ('/home/mysql ')) cdio_bak.sql mysql-5.5.16.tar.gz mm percona-xtrabackup-2.1.4-656-linux-i686.tar.gz mysql percona-xtrabackup-2.1.4-linux-i686 mysql-5.5.16 startmysql.sh ㈡ calls its own program [Python] > >> Import sh >>> r=sh. Command ('/root/dd.py ') >>> R () hello,dba ㈢bake commands parameters [Python] >>> Import sh >>> du=sh.du.bake ('-SHC ') >>> print (Du ('/home/mysql ')) 1.1g /home/mysql 1.1g Total ㈣glob listing files [python] >>> import sh >> > List=sh.glob ('/root/mm/* ') >>> Print List ['/root/mm/backup ', '/root/Mm/usplash ', '/root/mm/awn ', '/root/mm/wallpapers ', '/root/mm/grub ', '/root/mm/mozilla '] ㈤ pipeline [python] >>> Print (Sh.sort (Sh.du (Sh.glob (' * '), '-SHC '), '-rn ') 712k distribute-0.6.49.tar.gz 672k setuptools-1.1.5.tar.gz 548k get-pip.py Pipeline is ordered, by default from the inside out, but what if parallelism is required? Add a _piped=true [python] >>> for line in sh.tr (Sh.tail ("-F", "/home/mysql/mysql/log/alert.log", _ piped=true), "[: Upper:]", "[: Lower:]", _iter=true):  , .... Print line .. innodb: Doublewrite Buffer not found:creating new innodb:doublewrite buffer created innodb : 127 rollback Segment (s) active. innodb:creating FOREIGN KEY constraint system tables innodb:foreign key constraint System Tables created
Python SH Library learning