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:
|
else:
|
||||||
print("Connected to " + device["HostName"])
|
print("Connected to " + device["HostName"])
|
||||||
#Export config
|
#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")
|
print("Export commanded")
|
||||||
time.sleep(10) #Wait for ten seconds to make sure latest export is prepared before download
|
with open(file_path, "w") as f: #write export into file
|
||||||
|
f.writelines(stdout.readlines())
|
||||||
#Download Config
|
print("Export written into file")
|
||||||
ssh_client.open_sftp().get(device["Location"] + "_" + device["DeviceName"] + ".rsc", file_path)
|
|
||||||
print("File downloaded successfully!")
|
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
# Close the SSH connection
|
# Close the SSH connection
|
||||||
|
Loading…
x
Reference in New Issue
Block a user