标签:os.walk walk erro grep inpu index sys.argv odi lse
#!/usr/bin/env python
#coding:utf-8
import os
import re
import sys
script_name = sys.argv[0]
game_gen_path = ‘/data/bz-tw-and‘
def callable(input_args):
for (root,dirs,filename) in os.walk(game_gen_path):
for file in filename:
if re.match(input_args,file):
script_abs_path=os.path.join(root,file)
os.system(‘sh %s‘ % script_abs_path)
if re.match(input_args,‘status‘):
os.system(‘ps aux | grep bz-tw-and-s | grep -v grep‘)
try:
input_args = sys.argv[1]
except IndexError as e:
print(e)
print(‘Example: python %s start|stop|status‘ % script_name )
else:
callable(input_args)
标签:os.walk walk erro grep inpu index sys.argv odi lse
原文地址:http://blog.51cto.com/yht1990/2133082