Reputation: 9
i was trying to connect to a router and to just get the result of a one command the code is below :
from netmiko import ConnectHandler
router = { "device_type": "xxxx",
"host": "xxxx",
"username": "xxxx",
"password": "xxxx",
}
command = "show arp all"
net_connect= ConnectHandler(**router)
output = net_connect.send_command(command)
print(output)
and i get this error ' Error: Invalid parameter ^ ' i don't undrestand where is the problem !
Can someone figure out the error please !
Upvotes: 0
Views: 275
Reputation: 463
One another approach is to send "terminal length 0" command before sending "show arp all" command. You should also send "show arp all" command with netmiko timing method, so that all outputs should be collected till the bottom line.
command = "show arp all"
net_connect= ConnectHandler(**router)
net_connect.send_command("terminal length 0")
output = net_connect.send_command_timing(command) <<<<<<<<<<<<
Just a sample code helps to get "show interface description" data.
asr9k = {
"host" : "10.10.10.10",
"username" :"admin",
"password" :"admin",
"port" : 22,
"device_type" : "cisco_xr",
}
con = ConnectHandler(**asr9k)
con.enable()
data_to_parse = con.send_command_timing('show interface description')
Upvotes: 0
Reputation: 2266
I think the error is in the command itself. There is no all
in the command. Please consider sending show arp
or show ip arp
without . Check out this link. You can also add all
"session_log": "router.log"
to the router's dictionary and find the invalid parameter message in the router.log
file.
The log file shows you what is happening in the CLI on the device.
Try doing something like:
router = {
"device_type": "xxxx",
"host": "xxxx",
"username": "xxxx",
"password": "xxxx",
"session_log": "router.log" # <--- this line
}
cmd = "show arp" # or "show ip arp"
net_connect = ConnectHandler(**router)
arp_output = net_connect.send_command(cmd)
net_connect.disconnect() # to clear the vty line when done
print(arp_output)
Upvotes: 0