send_command_timing "copy tftp flash" to download sw from tftp server
See original GitHub issueHi, I want to do tftp with the below commands, to download sw from the server. What can I do to click the enter command after question?
From CLI, Manual config:
R#copy tftp:WANold.pcap bootflash: Address or name of remote host ->I need to type ip address for the first command run Source filename [WANold.pcap]? ->I need to click enter Destination filename [WANold.pcap]? -> i need to click enter Accessing tftp://10.10.12.145/WANold.pcap… Loading WANold.pcap from 10.10.12.145 (via GigabitEthernet0/0/0): ! [OK - 43655 bytes]
Python Script:
net_connect = Netmiko(**host1)
command1 = ("copy tftp:WANold.pcap bootflash:") # Enter set of commands
print("Connected to:", net_connect.find_prompt()) # Display hostname
output = net_connect.enable()
print(net_connect.find_prompt())
Tftp_server = "10.10.12.145"
output = net_connect.send_command_timing(command1)
if 'Address or name of remote host' in output:
output += net_connect.send_command_timing(Tftp_server)
if 'Source filename' in output:
# switch back to send_command() here as this might be slow
output += net_connect.send_command()
if 'Destination filename' in output:
# switch back to send_command() here as this might be slow
output += net_connect.send_command()
net_connect.disconnect() # Disconnect from Session
print(output)
Error:
Traceback (most recent call last): File “C:\Users\tftp-2.py”, line 29, in <module> output += net_connect.send_command() File “C:\Users\venv\lib\site-packages\netmiko\utilities.py”, line 429, in wrapper_decorator return func(self, *args, **kwargs) TypeError: send_command() missing 1 required positional argument: ‘command_string’
def select_cmd_verify(func): “”“Override function cmd_verify argument with global setting.”“”
@functools.wraps(func)
def wrapper_decorator(self, *args, **kwargs):
if self.global_cmd_verify is not None:
kwargs["cmd_verify"] = self.global_cmd_verify
return func(self, *args, **kwargs)
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Here are a couple of similar examples:
https://github.com/ktbyers/netmiko/blob/develop/EXAMPLES.md#handling-commands-that-prompt-timing
https://github.com/ktbyers/netmiko/blob/develop/EXAMPLES.md#handling-commands-that-prompt-expect_string
Hi Kirk,
I used a different command format and worked this time, thank you for the examples, they’re helping me a lot. Do you know somewhere that I can find paramiko examples as well?