|
- #!/usr/bin/python
- import os
- import sys
- cmd_services="ls /etc/init.d"
- os.system(cmd_services)
- print "Which service want to control?"
- service=raw_input()
- print "You have selected",service,
- print "service"
- print "You can start,stop or restart"
- order=raw_input()
- first="/etc/init.d/"+service
- first+=" "
- if order=="start":
- print "Starting",service,
- print "service"
- command=first+"start"
- os.system(command)
- elif order=="stop":
- print "Stopping",service,
- print "service"
- command=first+"stop"
- os.system(command)
- elif order=="restart":
- print "restarting",service,
- print "service"
- command=first+"restart"
- os.system(command)
- else:
- print "Command error,BYE!"
复制代码 |
|