53 lines
1.7 KiB
Python
53 lines
1.7 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/Remove_member1_CDN_VNPT_NTL.txt"
|
|
)
|
|
with open(log_file, "a") as log:
|
|
try:
|
|
time.sleep(2)
|
|
# 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("> " + 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("D:\Visual Studio Code\GetBaseLine\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))
|
|
# time.sleep(0.5)
|
|
# crt.Screen.Send("yes\n")
|
|
crt.Screen.WaitForString("assword:")
|
|
crt.Screen.Send("Hau@vng210701\n")
|
|
crt.Screen.WaitForString(">")
|
|
time.sleep(1)
|
|
getInfo()
|
|
|
|
crt.Screen.Send("quit \n")
|
|
crt.Screen.WaitForString("[haudt3@DC_CP_TERMINAL_PRI ~]$")
|
|
time.sleep(1)
|
|
|
|
crt.Dialog.MessageBox("Script completed. Check the log for details.")
|
|
|
|
|
|
main()
|