50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
import datetime
|
|
import os
|
|
import shutil
|
|
import time
|
|
|
|
|
|
def getInfo():
|
|
with open("D:/Visual Studio Code/GetBaseLine/command.txt", "r") as commands:
|
|
datacmd = commands.read()
|
|
commands_list = datacmd.splitlines()
|
|
log_file = "D:/Visual Studio Code/GetBaseLine/Result/result2.txt"
|
|
with open(log_file, "a") as log:
|
|
try:
|
|
time.sleep(2)
|
|
log.write("\n\n")
|
|
logtime = datetime.datetime.now()
|
|
log.write(str(logtime))
|
|
log.write(
|
|
"\n---------------------------------------------------------------------------------------------------------------------------\n"
|
|
)
|
|
for command in commands_list:
|
|
crt.Screen.Send(command + "\r")
|
|
response = crt.Screen.ReadString(">")
|
|
log.write("> " + command + response)
|
|
time.sleep(1)
|
|
except Exception as e:
|
|
log.write("Error occurred: " + str(e))
|
|
crt.Dialog.MessageBox("Error occurred: " + str(e))
|
|
|
|
|
|
def main():
|
|
with open("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("Hau@vng0701\n")
|
|
crt.Screen.WaitForString(">")
|
|
time.sleep(2)
|
|
getInfo()
|
|
|
|
crt.Screen.Send("quit \n")
|
|
crt.Screen.WaitForString("haudt3@dc-epz-ops-ter-pri:~$")
|
|
|
|
crt.Dialog.MessageBox("Script completed. Check the log for details.")
|
|
|
|
|
|
main()
|