Get_Baseline/getbaseline_TTEPZ.py

50 lines
1.6 KiB
Python
Raw Normal View History

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-14 00:06:46 +07:00
log_file = r"D:\Visual Studio Code\GetBaseLine-old\Result\C105489_960-1_afterchange.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:
crt.Screen.Send("ssh haudt3@%s \n" % (ip))
crt.Screen.WaitForString("assword:")
2025-11-14 00:06:46 +07:00
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()
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()