2023-08-29 01:16:23 +07:00
|
|
|
import datetime
|
|
|
|
|
import os
|
|
|
|
|
import shutil
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getInfo():
|
2025-11-13 20:18:23 +07:00
|
|
|
with open("D:\Visual Studio Code\GetBaseLine-old\command.txt", "r") as commands:
|
2023-08-29 01:16:23 +07:00
|
|
|
datacmd = commands.read()
|
|
|
|
|
commands_list = datacmd.splitlines()
|
2025-11-22 06:36:05 +07:00
|
|
|
log_file = r"D:\Visual Studio Code\GetBaseLine-old\Result\240727W0050.txt"
|
2023-08-29 01:16:23 +07:00
|
|
|
with open(log_file, "a") as log:
|
|
|
|
|
try:
|
2025-11-13 20:18:23 +07:00
|
|
|
time.sleep(1)
|
2023-08-29 01:16:23 +07:00
|
|
|
logtime = datetime.datetime.now()
|
|
|
|
|
log.write(str(logtime))
|
|
|
|
|
log.write(
|
2025-11-13 20:18:23 +07:00
|
|
|
"\n\n---------------------------------------------------------------------------------------------------------------------------\n"
|
2023-08-29 01:16:23 +07:00
|
|
|
)
|
|
|
|
|
for command in commands_list:
|
2025-11-13 20:18:23 +07:00
|
|
|
crt.Screen.Send(command + "\n")
|
2023-08-29 01:16:23 +07:00
|
|
|
response = crt.Screen.ReadString(">")
|
2025-11-13 20:18:23 +07:00
|
|
|
# log.write( response)
|
|
|
|
|
log.write("> " + response)
|
|
|
|
|
time.sleep(0.5)
|
2023-08-29 01:16:23 +07:00
|
|
|
except Exception as e:
|
|
|
|
|
log.write("Error occurred: " + str(e))
|
|
|
|
|
crt.Dialog.MessageBox("Error occurred: " + str(e))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2025-11-13 20:18:23 +07:00
|
|
|
with open("D:\Visual Studio Code\GetBaseLine-old\ip_device.txt", "r") as commands:
|
2023-08-29 01:16:23 +07:00
|
|
|
dataIP = commands.read()
|
|
|
|
|
list_ip_device = dataIP.splitlines()
|
|
|
|
|
for ip in list_ip_device:
|
2025-11-22 06:36:05 +07:00
|
|
|
#crt.Screen.Send("ssh %s \n" % (ip))
|
|
|
|
|
# crt.Screen.Send("cli \n")
|
|
|
|
|
#crt.Screen.WaitForString("assword:")
|
|
|
|
|
#crt.Screen.Send("&Mx4G5cu*s$ZOf\n")
|
2023-08-29 01:16:23 +07:00
|
|
|
crt.Screen.WaitForString(">")
|
2025-11-13 20:18:23 +07:00
|
|
|
time.sleep(0.5)
|
2023-08-29 01:16:23 +07:00
|
|
|
getInfo()
|
|
|
|
|
|
2025-11-22 06:36:05 +07:00
|
|
|
#crt.Screen.Send("quit \n")
|
2025-11-13 20:18:23 +07:00
|
|
|
time.sleep(1)
|
2023-08-29 01:16:23 +07:00
|
|
|
|
|
|
|
|
crt.Dialog.MessageBox("Script completed. Check the log for details.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main()
|