Terminal export is written into file.
This commit is contained in:
parent
dfd25c3a47
commit
b3623c8ebe
10
main.py
10
main.py
@ -30,13 +30,11 @@ for device in devices:
|
||||
else:
|
||||
print("Connected to " + device["HostName"])
|
||||
#Export config
|
||||
ssh_client.exec_command("export file=" + device["Location"] + "_" + device["DeviceName"] + ".rsc show-sensitive")
|
||||
stdin, stdout, stderr= ssh_client.exec_command("export show-sensitive")
|
||||
print("Export commanded")
|
||||
time.sleep(10) #Wait for ten seconds to make sure latest export is prepared before download
|
||||
|
||||
#Download Config
|
||||
ssh_client.open_sftp().get(device["Location"] + "_" + device["DeviceName"] + ".rsc", file_path)
|
||||
print("File downloaded successfully!")
|
||||
with open(file_path, "w") as f: #write export into file
|
||||
f.writelines(stdout.readlines())
|
||||
print("Export written into file")
|
||||
|
||||
finally:
|
||||
# Close the SSH connection
|
||||
|
Loading…
x
Reference in New Issue
Block a user