Hi fgimian i am new in python and i have faced with problem, this error occure randomly. Sometimes cycle can be 3 and more itteration sometimes it error occure in first itterattion.
Thank you for the Help!
from __future__ import print_function
import os
import traceback
import paramiko.
from paramiko_expect import SSHClientInteraction
import re
import time
date = time.strftime("_%Y_%m_%d_%H_%M_%S")
host = '1.2.2.4'
user = '1233'
secret = '123'
#File with devices
devices = "devices".
ftp_srv = "1.0.1.5"
conf_path = "/var/ftp/"
l_dev = open(devices, 'r+')
dev = l_dev.readlines()
l_dev.close()
for i in dev:
i = i.strip().split(' ')
if i[0] in ["SWITCH"]:
dev_name = (i[1][:-1])
if not os.path.exists(conf_path + dev_name):
os.makedirs(conf_path + dev_name)
os.chmod(conf_path + dev_name, 655)
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=i[2], username=user, password=secret)
with SSHClientInteraction(ssh, timeout=10, display=True) as interact:
interact.expect(i[1])
interact.send('copy running-config ftp:/' + dev_name + '/')
interact.expect("Address or name of remote.*")
interact.send(ftp_srv)
interact.expect("Destination filename.*")
interact.send(dev_name + '/' + dev_name + date)
interact.send('exit')
interact.expect()
cmd_output_uname = interact.current_output_clean
ssh.close()
time.sleep(5)
FL-4_SW01#Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/paramiko/channel.py", line 683, in recv
out = self.in_buffer.read(nbytes, self.timeout)
File "/usr/local/lib/python3.7/site-packages/paramiko/buffered_pipe.py", line 160, in read
raise PipeTimeout()
paramiko.buffered_pipe.PipeTimeout
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./coll_conf.py", line 39, in
interact.expect(i[1])
File "/usr/local/lib/python3.7/site-packages/paramiko_expect.py", line 144, in expect
current_buffer = self.channel.recv(self.buffer_size)
File "/usr/local/lib/python3.7/site-packages/paramiko/channel.py", line 685, in recv
raise socket.timeout()
socket.timeout
@directum still facing this issue ?
since I don't know the exact devices or environment you are using, a bit hard to guess where the timeoit is coming from
Hi fgimian i am new in python and i have faced with problem, this error occure randomly. Sometimes cycle can be 3 and more itteration sometimes it error occure in first itterattion.
Thank you for the Help!