上一页 1 ··· 82 83 84 85 86 87 88 89 90 ··· 100 下一页
摘要: 执行结果: [root@localhost ~]# python backup.py ('Successfully created directory', '/root/backup/20170918')Zip command is:zip -r /root/backup/20170918/2321 阅读全文
posted @ 2017-09-19 11:07 Oops!# 阅读(381) 评论(0) 推荐(0) 编辑
摘要: 执行格式: ./set_bridge.sh -i 192.168.4.72 -g 192.168.4.1 结果: [root@localhost ~]# ifconfigbr0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192 阅读全文
posted @ 2017-09-19 08:57 Oops!# 阅读(1208) 评论(0) 推荐(0) 编辑
摘要: 使用正则表达式收集主机信息 #!/usr/bin/env python from subprocess import Popen, PIPE import re def getIfconfig(): p = Popen(['ifconfig'], stdout=PIPE) data = p.stdo 阅读全文
posted @ 2017-09-14 16:48 Oops!# 阅读(234) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python from subprocess import Popen, PIPE def getIfconfig(): p = Popen(['ifconfig'], stdout=PIPE) data = p.stdout.read() return data de 阅读全文
posted @ 2017-09-14 16:24 Oops!# 阅读(250) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python from subprocess import Popen, PIPE def getIfconfig(): p = Popen(['ifconfig'], stdout=PIPE) data = p.stdout.read().split('\n\n') 阅读全文
posted @ 2017-09-14 16:09 Oops!# 阅读(225) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python from subprocess import Popen, PIPE p = Popen(['dmidecode'], stdout=PIPE) data = p.stdout lines = [] dmi = {} a = True while a: l 阅读全文
posted @ 2017-09-14 15:46 Oops!# 阅读(428) 评论(0) 推荐(0) 编辑
摘要: 按字典值排序 按照字典value排序,类似sort -k 命令 import operator x= {1:2,3:4,4:3,2:1,0:0} sorted_x = sorted(x.iteritems(), key=operator.itemgetter(1)) In [38]: sorted_ 阅读全文
posted @ 2017-09-14 14:40 Oops!# 阅读(184) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python import sys import hashlib def md5sum(f): m = hashlib.md5() with open(f) as fd: while True: data = fd.read(4096) if data: m.updat 阅读全文
posted @ 2017-09-14 14:17 Oops!# 阅读(175) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/python import sys import os try: fn = sys.argv[1] except IndexError: print "please follow a argument at %s" % __file__ sys.exit() if not os 阅读全文
posted @ 2017-09-14 11:48 Oops!# 阅读(563) 评论(0) 推荐(0) 编辑
摘要: vim wc.py #!/usr/bin/python def wordCount(s): chars = len(s) words = len(s.split()) lines = s.count('\n') print lines, words, chars if __name__ == '__ 阅读全文
posted @ 2017-09-14 11:11 Oops!# 阅读(250) 评论(0) 推荐(0) 编辑
上一页 1 ··· 82 83 84 85 86 87 88 89 90 ··· 100 下一页