2010-10-13 67 views

回答

0

這樣來做:

subprocess.call(['/etc/init.d/tomcat6', 'stop']) 

,或者,如果你真的需要捕捉到標準輸出/錯誤

p = subprocess.Popen(['/etc/init.d/tomcat6', 'stop'], 
        stdout=subprocess.PIPE, 
        stderr=subprocess.PIPE) 
stdout, stderr = p.communicate()