« 倒序输出数组FlashGet 1.9 (FTP PWD Response) 0day Remote Buffer Overflow PoC Exploit »
August 14 2008

重启&关机

Tags: 重启  关机   djhui @ 9:20

#!/usr/bin/python
#coding=utf-8
import time
from os import system
runing = True
while runing:
    input = raw_input('关机(s)OR重启(r)?(q退出)')
    input = input.lower()
    if input == 'q' or input =='quit':
        runing = False
        print '程序退出'
        break
    seconds = int(raw_input('请输入暂停时间(单位:秒):'))
    time.sleep(seconds)
    print '暂停时间:', seconds
    runing = False
   
    if input == 's':
        print '关机ing'
#windows下用这句
#        system('shutdown -s -t 0')
        system('halt')
    elif input == 'r':
        print '重启ing'
#其实这里就是调用了系统的命令,包括上面的关机
#windows下用这句
#        system('shutdown -r -t 0')
        system('reboot')
    else:
        print '程序错误重新输入'
        runing = True
print '程序结束~~~!'

#而这个程序之所以是在Linux下有效,而windows下无效就是其中的命令有差异

  • 相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。