Get_Baseline/getbaseline_TTEPZ.py
2025-11-13 20:18:23 +07:00

50 lines
1.6 KiB
Python

import datetime
import os
import shutil
import time
def getInfo():
with open("D:\Visual Studio Code\GetBaseLine-old\command.txt", "r") as commands:
datacmd = commands.read()
commands_list = datacmd.splitlines()
log_file = r"D:\Visual Studio Code\GetBaseLine-old\Result\prepend-as_igw_afterchange.txt"
with open(log_file, "a") as log:
try:
time.sleep(1)
logtime = datetime.datetime.now()
log.write(str(logtime))
log.write(
"\n\n---------------------------------------------------------------------------------------------------------------------------\n"
)
for command in commands_list:
crt.Screen.Send(command + "\n")
response = crt.Screen.ReadString(">")
# log.write( response)
log.write("> " + response)
time.sleep(0.5)
except Exception as e:
log.write("Error occurred: " + str(e))
crt.Dialog.MessageBox("Error occurred: " + str(e))
def main():
with open("D:\Visual Studio Code\GetBaseLine-old\ip_device.txt", "r") as commands:
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:")
crt.Screen.Send("N^Qt#^L00zD#mj\n")
crt.Screen.WaitForString(">")
time.sleep(0.5)
getInfo()
crt.Screen.Send("quit \n")
time.sleep(1)
crt.Dialog.MessageBox("Script completed. Check the log for details.")
main()