-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Function net_connect.send_command, rstrip error #167
Comments
@wmann So change this: To this: |
I should learn more python ;-( |
But this |
Damn, it might be to late for coding today. |
Just use a for loop and gather the output. show_commands = ['show system', 'show interfaces transceiver'] output = '' for cmd in show_commands: output += net_connect.send_command(cmd, delay_factor=2) Each time through the loop 'cmd' will be set to one of the commands. |
As the HP Procurve switches could run show commands in config mode. There was no problem using net_connect.send_config_set command for show commands. This works fine.
Code looks like this:
SSHClass = netmiko.ssh_dispatcher(device_type=switch['device_type'])
net_connect = SSHClass(**switch)
show_commands = ['show run']
output = net_connect.send_config_set(show_commands, delay_factor=2)
This works fine. Now I want to use the send_command function. I replaced send_config_set with send_command so the code looks like this
SSHClass = netmiko.ssh_dispatcher(device_type=switch['device_type'])
net_connect = SSHClass(**switch)
show_commands = ['show run']
output = net_connect.send_command(show_commands, delay_factor=2)
With this function I get the following error:
Traceback (most recent call last):
File "script.py", line 33, in
output = net_connect.send_command(show_commands, delay_factor=2)
File "C:\Python27\lib\site-packages\netmiko\base_connection.py", line 355, in send_command
command_string = command_string.rstrip("\n")
AttributeError: 'list' object has no attribute 'rstrip'
Any idea how to fix this?
Best Regards
wmann
The text was updated successfully, but these errors were encountered: