::NPTEAM:: Network Programer Team

검색 :
RSS 구독 : 글 / 댓글 / 트랙백 / 글+트랙백

[Python] ExecuteCmd 커맨드 명령어 실행하기

Python에서 Command 명령어 실행하는 예제
import os
import subprocess

def ExecuteCmd(strCmd):
	print '[ExcuteCmd] ' + strCmd
	pipe = subprocess.Popen(strCmd, stdout=subprocess.PIPE)
	
	retCode = pipe.wait()
	retResult = pipe.stdout.read()
	
	return retCode, retResult
	
def main():
	(retCode, retResult) = ExecuteCmd('svn --version')
	print 'retCode : ' + str(retCode)
	print retResult
		
if __name__ == "__main__":
	try:
		main()
	except os.error, err:
		print str(err)
2012/01/19 11:41 2012/01/19 11:41

맨 위로