# encoding: utf-8 #有中文需加这个
import os,logging
logging.basicConfig(level = logging.INFO,format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger=logging.getLogger(__name__)
def exec_cmd(cmd):
if cmd.startswith('w'):
print '%s not valid' % cmd
else:
ret=os.system(cmd)
if ret!=0:
print "cmd \"%s\"执行失败" % cmd
else:
logger.info("FATAL: exec cmd \"%s\" return %d.", cmd, ret)
if __name__=="__main__":
cmd="pwd"
exec_cmd(cmd)
网友评论