pythonansibleciscocisco-ios

Issue connecting to cisco ios switch with custom menu enabled


I am trying to connect to a Cisco [Cisco IOS Software, C2900 Software (C2900-UNIVERSALK9-M), Version 15.4(3)M3] switch via ansible/python. But I am facing issue because we have enabled a menu when we connect to vty.

Is there any working sample someone can point me towards where I could pass thru this menu and run commands as usual?

Use of this system by unauthorized persons or in an unauthorized manner is prohibited.



******************************************************************************

*         Banner              *

******************************************************************************

    1          option 1

    2          option 2

    16        option 16

    X          Exec Prompt

    W          Who is connected

    R          Resume the last connection

    C          Close the last connection

    Z          Logout

    32         Available

Enter Selection: X

switch1>

Thanks


Solution

  • You should use expect, or the pexpect python implementation.

    A sample workflow: