I want to create a simple program in python that save all the services that run on my ubuntu linux computer. I want it to be as simple as possible when save maximum information about the services. What is the best way to do so? Is there a library that I can use?
thanks.
Use this:
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])
You could also change the command service --status-all
to any other shell supported command you would like.
Hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.