2011年8月18日

python调用Shell脚本:os.system(cmd)或os.popen(cmd)()【转】

摘要: python调用Shell脚本,有两种方法:os.system(cmd)或os.popen(cmd),前者返回值是脚本的退出状态码,后者的返回值是脚本执行过程中的输出内容。实际使用时视需求情况而选择。 现假定有一个shell脚本test.sh: #!/bin/bash 1. echo "hello world!" 2. exit 3 os.system(cmd): 该方法在调用完shell脚本后,... 阅读全文

posted @ 2011-08-18 15:05 Cheney Shen 阅读(7344) 评论(0) 推荐(0) 编辑

导航