Cmd控制
昨天看到了别的组的部署方案,使用python来控制的,我们是用shell
今天尝试了一下
code
import os
import sys
from cmd import Cmd
class BingCmd(Cmd):
"""just try try"""
prompt="BingCmd>"
def print_log(self, argv):
print("la la la ")
def do_bing(self, argv):
self.print_log(argv)
def help_bing(self):
print("just print la la la")
if __name__ == "__main__":
# import IPython
# IPython.embed()
BingCmd().cmdloop()
运行结果
$ python3 BingCmd.py
BingCmd>help
Documented commands (type help <topic>):
========================================
bing help
BingCmd>bing
la la la