An interactive script that uses Python to write an imitation router command

Source: Internet
Author: User

Just started to learn python, the power of the sensory function. Since the start is learning the network so familiar with the command line configuration of the router switch, so simply write a copy h3c interactive script. Because it is beginner, it only involves simple while loop and if condition judgment. Can be used as an interactive program of thought framework.


#!/usr/bin/env python__author__ =  ' Administrator ' Print (' \ n ' + ' View-sys ', "\ n") While true:     usr_view=input ("<Router>")     if usr_view== "": Continue     elif usr_view== ' quit '  or usr_view== ' qu ':         quit ()     while usr_view== ' sys '  or usr_view== ' System-view '  and usr_view!= ' Quit ':         sys_view=input (' [Router] ')         if sys_view== "":continue         elif sys_view== ' quit '  or sys_view== ' qu ':             break        while sys_view== ' INTERFACE&NBSP;E0/0/1 '  or sys_view== ' INT&NBSP;E0/0/1 ':            &Nbsp;interface_view=input (' [ROUTER--ETHERNET0/0/1] ')              if interface_view== "":continue             elif interface_view== ' quit ' or interface_view== ' qu ':                 break             else:                 print ('  % unrecognized command ')          else:             print ('  % unrecognized command ')     else:         print ('  % unrecognized command ')


This article is from the "7070206" blog, please be sure to keep this source http://7080206.blog.51cto.com/7070206/1569177

An interactive script that uses Python to write an imitation router command

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.