[英]Python - how to get the services that run on my computer
我想在python中創建一個簡單的程序,保存在我的ubuntu linux計算機上運行的所有服務。 在保存有關服務的最大信息時,我希望它盡可能簡單。 這樣做的最佳方法是什么? 我有可以使用的圖書館嗎?
謝謝。
用這個:
import subprocess
subprocess.Popen('service --status-all', stdout=subprocess.PIPE).stdout.read()
import subprocess
sp = subprocess.Popen("service --status-all", stdout=subprocess.PIPE).communicate()
print 'Services output: {0}'.format(sp[0])
您還可以將命令service --status-all
更改為您希望的任何其他shell支持的命令。
希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.