Netmiko: How to search in switch using a variable

Viewed 108

I am not getting any output if I am doing this.

mac_address=abcd
output=net_connect.send_command('show mac-address-table | inc mac_address')
print("Output of the switch  ",output)


I am getting the desired output if I am doing this.

output=net_connect.send_command('show mac-address-table | inc abcd')
print("Output of the switch  ",output)


What should I make change in the code so that I can use variable?

1 Answers

The closing quote in the first example is after mac_address, making that literal text, not a variable. I'm not sure how you append two strings, but something like:

output=net_connect.send_command('show mac-address-table | inc '+mac_address)

where the + is appending the literal string and the variable string.

Related