Reputation: 99
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.
Upvotes: 1
Views: 90
Reputation: 83
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.
Upvotes: 1
Reputation: 3069
Use this:
import subprocess
subprocess.Popen('service --status-all', stdout=subprocess.PIPE).stdout.read()
Upvotes: 2