Tuesday, June 4, 2019

Netmiko copy tftp script not working

from netmiko import ConnectHandler

from getpass import getpass

import ipaddress

import time

from ipaddress import IPv4Address, IPv4Network

from datetime import datetime

rtr1 = {

`'device_type': 'cisco_ios',` `'ip' : '`[`172.28.1.1`](https://172.28.1.1)`',` `'username' : 'test',` 

'password' : 'test',

'secret' : 'test',

}

net_connect = ConnectHandler(**rtr1)

net_connect.enable()

output = net_connect.send_command('copy tftp://172.28.1.26/new_99_rtr.txt flash' + "\n")

print output

Hello folks, no matter wtf I do, I just can't get this script to copy a file from tftp server to Router. I think it's all because of that 2nd enter/return I need to push to copy the file. No matter how I modify the "\n" I can't get it to work. When I go into the Router and type "show history all", it shows that it inputs the command and presses enter, but can never press enter the 2nd time to get it to copy the file such as this:

RT001#copy tftp://172.28.1.26/new_99_rtr.txt flash

Destination filename [new_99_rtr.txt]? Press enter once......

Accessing tftp://172.28.1.26/new_99_rtr.txt...Press enter twice........

Loading new_99_rtr.txt from 172.28.1.26 (via Serial0/1/0:0): !

[OK - 9469 bytes]

WOrks just fine when I do it from the Router, yet in the script, the script just sits there and thinks all day... I've tried adding more \n\n\n no matter what it just does not work. really annoying issue, I hope someone knows of a really dumb mistake I'm making here.



No comments:

Post a Comment