forked from ucadatalab/u-cyber-lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreboot.py
21 lines (18 loc) · 998 Bytes
/
reboot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from tiempo import tiempo
import json
import re
def reboot(ssh):
print("El dispositivo se reiniciará a las: ")
time_string = tiempo(ssh)
print(time_string) #Hora en la cual el dispositivo se reiniciará
stdin, stdout1, stderr = ssh.exec_command('/system script remove [/system script find]') #Elimina todos los scripts
stdin, stdout2, stderr = ssh.exec_command('/system scheduler remove [/system scheduler find]') #Elimina todos los planificadores del dispositivo
stdout = stdout2.readlines()
print(stdout)
print(time_string)
stdin, stdout3, stderr = ssh.exec_command('/system script add name="reinicio" source="/system reboot"') #
stdin, stdout4, stderr = ssh.exec_command('/system scheduler add name=reinicio start-time='+time_string+' on-event=reinicio') #
stdout = stdout4.readlines()
#print('/system scheduler add name=reinicio start-time='+time_string+'on-event=reinicio')
print(stdout)
print("Reiniciando...")