question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cisco SG350-10 - Not much working....

See original GitHub issue

Been trying to use netmiko to write a script for a Cisco SG350-10 and not having much luck. All the videos on YouTube made it look so simple haha.

from netmiko import Netmiko
from getpass import getpass

cisco_switch = {
    "host": "192.168.1.17",  # input("Host: "),
    "username": "damien",  # input("Username: "),
    "password": "Cisco12345",  # getpass(),
    "device_type": "cisco_ios"
}

connection = Netmiko(**cisco_switch)
prompt = connection.find_prompt()
print(prompt)

output = connection.send_command("show vlan")
print(output)

connection.disconnect()

This outputs:

[Running] py -u "c:\Users\Damien Butt\Norgate AV Dropbox\Damien Butt\Resources\Crestron\Cisco NVX Setup\cisco_nvx_setup.py"
switch28798b#
Traceback (most recent call last):
  File "c:\Users\Damien Butt\Norgate AV Dropbox\Damien Butt\Resources\Crestron\Cisco NVX Setup\cisco_nvx_setup.py", line 33, in <module>
    output = connection.send_command("show vlan")
  File "C:\Users\Damien Butt\AppData\Local\Programs\Python\Python38\lib\site-packages\netmiko\base_connection.py", line 1405, in send_command
    raise IOError(
OSError: Search pattern never detected in send_command_expect: \[Kswitch28798b\#

[Done] exited with code=1 in 111.877 seconds

It seems to find the prompt fairly quickly, although it has some extra chars at the start. Then it hangs for a long time before the exception is thrown. I think it’s something to do with those extra chars in the prompt perhaps. They shouldn’t be there.

I’ve also tried using the send_config_set method and that also throws exceptions.

However, if I use the send_command method and specify the “expect_string” parameter as follows:

output = connection.send_command("show vlan", expect_string=r"#"))

That works and outputs:

[Running] py -u "c:\Users\Damien Butt\Norgate AV Dropbox\Damien Butt\Resources\Crestron\Cisco NVX Setup\cisco_nvx_setup.py"
switch28798b#
Created by: D-Default, S-Static, G-GVRP, R-Radius Assigned VLAN, V-Voice VLAN

Vlan       Name           Tagged Ports      UnTagged Ports      Created by    
---- ----------------- ------------------ ------------------ ---------------- 
 1           1                               gi1-10,Po1-8           DV        

switch28798b#

[Done] exited with code=0 in 8.329 seconds

Ideally, I need to use the send_config_set method as I have a bunch of commands to send.

Any ideas what the problem could be?

Thanks in advance.

Damien

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gabycommented, May 12, 2022

@ktbyers That’s exactly the issue, it’s missing from the dict. I’d try making a PR for this during the weekend.

1reaction
ktbyerscommented, May 12, 2022

@gaby Did you check if it is supported by ssh_autodetect? If not, someone would need to add that support.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is SG-350 10-port managed switch a non-working piece of ...
I am a very frustrated first time customer. This is my first time using Cisco equipment, and I didn't expect the technical phone...
Read more >
Solved: Cisco SG350-10 reset issue
Bought an SG350-10 switch recently to use in my home lab I'm setting a static IP on the switch and all is working...
Read more >
CISCO SG350-10 losing its configuration? - Cisco Community
We have a few cases where the configuration of the switches gets lost and they jump back to their factory default. Now about...
Read more >
Solved: Cisco SG350-10 strange behaviour with IP camera
I am using the cisco SG350-10 in DHCP server mode with an IP camera and it sometimes work and sometimes not. When I...
Read more >
Solved: Configuring a new SG350-10 Switch - Cisco Community
Solved: I just took a new SG350-10 out of the box and am trying to do (what ... I have this problem too...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found