Command line processing method and apparatus, network device, and computer readable storage medium
Patent Information
- Application Number
- CN202211677624.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-26
- Publication Date
- 2026-09-29
- Estimated Expiration
- 2042-12-26
AI Technical Summary
[0004]有鉴于此,本发明的目的在于提供一种命令行处理方法、装置、网络设备和计算机可读存储介质,以解决现有技术中存在的内存占用多、命令行解析慢和初始化启动慢的问题
[0028]本发明实施例提供的命令行处理方法、装置、网络设备和计算机可读存储介质,网络设备中预先存储有命令行配置文件和命令行加载文件,命令行配置文件包括网络设备的各业务模块的命令行信息,命令行加载文件包括指定业务模块的模块标识;网络设备在启动时,获取命令行加载文件中的指定业务模块的模块标识,并根据指定业务模块的模块标识,从命令行配置文件中获取指定业务模块的命令行信息,将指定业务模块的命令行信息加载到内存中,生成内存命令树。通过在命令行加载文件中以模块的粒度指定要加载哪些业务模块的命令行信息,使得网络设备启动时,只会从命令行配置文件中加载指定业务模块的命令行信息,其它业务模块的命令行信息仍然存储在命令行配置文件中,实现了只需加载少量命令行信息到内存中,故能缩短设备启动时间;同时,设备内存中只保留了指定业务模块的命令行信息,故内存中的命令树比较小,减少了内存资源消耗,提高了命令行解析效率。
Smart Images

Figure CN118264523B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology, and more specifically, to a command line processing method, apparatus, network device, and computer-readable storage medium. Background Technology
[0002] Command-line interfaces are widely used as a device management solution in network devices such as switches and routers, and can be used to manage network devices.
[0003] As network devices support increasingly richer service functions, the number of command lines registered in the network devices will also increase, leading to a growing command tree in the device's memory. An excessively large command tree will consume a significant amount of memory resources, resulting in slow parsing of individual command lines. Furthermore, during the device system startup phase, the large number of command line registrations by service modules will lead to longer startup times. Summary of the Invention
[0004] In view of this, the purpose of the present invention is to provide a command line processing method, apparatus, network device and computer-readable storage medium to solve the problems of high memory consumption, slow command line parsing and slow initialization startup in the prior art.
[0005] To achieve the above objectives, the technical solutions adopted in the embodiments of the present invention are as follows:
[0006] In a first aspect, the present invention provides a command-line processing method applied to a network device, wherein the network device pre-stores a command-line configuration file and a command-line loading file, the command-line configuration file including command-line information of each service module of the network device, and the command-line loading file including a module identifier specifying the service module; the method includes:
[0007] When the network device starts up, obtain the module identifier of the specified service module in the command-line loading file;
[0008] Based on the module identifier of the specified business module, obtain the command line information of the specified business module from the command line configuration file;
[0009] The command line information of the specified business module is loaded into memory to generate a memory command tree.
[0010] In an optional implementation, the network device is communicatively connected to a command-line management server; the command-line configuration file is generated by the command-line management server based on the command-line information of each service module input by the user and sent to the network device; the command-line management server also generates a command manual for the network device based on the command-line information of each service module input by the user.
[0011] In an optional implementation, the command line information includes the command line and its associated information; the method further includes:
[0012] When a user command is obtained, the system queries the memory command tree to see if a target command line matching the user command exists.
[0013] If a target command line matching the user command exists in the memory command tree, the target command line is executed according to its association information.
[0014] In an optional implementation, the method further includes:
[0015] If no target command line matching the user command exists in the memory command tree, the target command line matching the user command is obtained from the command line configuration file, and the target command line is executed according to the association information of the target command line.
[0016] In an optional implementation, the network device pre-stores a correspondence between the index values of command processing functions and their function addresses, and the associated information of the command line includes the index value of the command processing function corresponding to the command line; executing the target command line according to the associated information of the target command line includes:
[0017] Based on the index value in the association information of the target command line and the correspondence, obtain the function address of the command processing function corresponding to the target command line;
[0018] The command processing function corresponding to the target command line is called based on its function address.
[0019] In an optional implementation, the command-line configuration file is an XML file, and the command-line information in the command-line configuration file is organized in a tree structure.
[0020] Secondly, the present invention provides a command-line processing apparatus applied to a network device, wherein the network device pre-stores a command-line configuration file and a command-line loading file, the command-line configuration file including command-line information of each service module of the network device, and the command-line loading file including a module identifier specifying the service module; the apparatus includes:
[0021] The acquisition module is used to acquire the module identifier of a specified service module in the command-line loading file when the network device starts up;
[0022] The lookup module is used to retrieve the command-line information of the specified business module from the command-line configuration file based on the module identifier of the specified business module.
[0023] The loading module is used to load the command line information of the specified business module into memory and generate a memory command tree.
[0024] In an optional implementation, the command line information includes a command line and associated information of the command line; the device further includes:
[0025] The execution module is used to, when a user command is obtained, query whether there is a target command line matching the user command in the memory command tree; if there is a target command line matching the user command in the memory command tree, execute the target command line according to the association information of the target command line; if there is no target command line matching the user command in the memory command tree, obtain the target command line matching the user command from the command line configuration file, and execute the target command line according to the association information of the target command line.
[0026] Thirdly, the present invention provides a network device including a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the command line processing method as described in any of the foregoing embodiments.
[0027] Fourthly, the present invention provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the command-line processing method as described in any of the foregoing embodiments.
[0028] The command-line processing method, apparatus, network device, and computer-readable storage medium provided in this invention include a network device that pre-stores a command-line configuration file and a command-line loading file. The command-line configuration file includes command-line information for each service module of the network device, and the command-line loading file includes a module identifier for a specified service module. When the network device starts up, it obtains the module identifier of the specified service module from the command-line loading file, and based on the module identifier, retrieves the command-line information of the specified service module from the command-line configuration file. The command-line information of the specified service module is then loaded into memory, generating a memory command tree. By specifying which service module's command-line information to load at the module level in the command-line loading file, the network device only loads the command-line information of the specified service module from the command-line configuration file during startup. The command-line information of other service modules remains stored in the command-line configuration file. This achieves the goal of loading only a small amount of command-line information into memory, thus shortening device startup time. Simultaneously, since only the command-line information of the specified service module is retained in the device's memory, the command tree in memory is smaller, reducing memory resource consumption and improving command-line parsing efficiency.
[0029] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0030] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0031] Figure 1 A flowchart illustrating a command line processing method provided in an embodiment of the present invention is shown.
[0032] Figure 2 A network topology diagram of a network device and a command-line management server provided in an embodiment of the present invention is shown;
[0033] Figure 3 This paper illustrates another flowchart of the command line processing method provided in an embodiment of the present invention.
[0034] Figure 4 A functional block diagram of a command line processing device provided in an embodiment of the present invention is shown;
[0035] Figure 5 Another functional block diagram of the command line processing device provided in an embodiment of the present invention is shown;
[0036] Figure 6 A block diagram of a network device provided in an embodiment of the present invention is shown.
[0037] Icons: 100 - Network device; 200 - Command line management server; 600 - Command line processing device; 110 - Memory; 120 - Processor; 130 - Communication module; 610 - Acquisition module; 620 - Search module; 630 - Loading module; 640 - Execution module. Detailed Implementation
[0038] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0039] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0040] It should be noted that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0041] As network devices support increasingly richer service functions, the number of command lines registered in network devices will also increase, leading to a growing command tree in the device's memory, which in turn causes the following four problems.
[0042] 1. An excessively large command tree will consume a significant amount of system memory storage resources. Currently, memory modules are relatively expensive, and many network devices have limited memory. An excessively large command tree consumes a considerable amount of memory resources.
[0043] 2. An excessively large command tree leads to decreased parsing performance for individual command lines. The command tree is a tree structure; as the number of command lines increases, the structure of the command tree becomes increasingly complex, consequently reducing the parsing efficiency of individual command lines.
[0044] 3. During system startup, the registration of numerous command lines by business modules leads to excessively long startup times. In many application scenarios, network devices have specific startup time requirements, such as needing to complete startup within 90 seconds. However, during startup, most business modules continuously register a large number of command lines to the command tree, a time-consuming process that contributes to the extended startup time.
[0045] 4. The numerous additions, deletions, and modifications to command lines make it difficult to write and maintain device command manuals. Each project develops certain functions for a specific device, which leads to changes in some command lines displayed by the device. Whenever a project is released, project managers need to review all the additions, deletions, and changes to command lines in the project, and then notify developers and testers to make modifications and verifications. The entire process is inefficient and prone to errors.
[0046] To address the problems of excessively large command trees consuming significant memory resources, slow parsing and execution of individual command lines, prolonged startup times due to numerous command line registrations for various business modules, and difficulties in maintaining device command manuals due to frequent additions, deletions, and modifications of command lines, this invention provides a command line processing method, apparatus, network device, and computer-readable storage medium. By specifying which business module's command line information to load in the command line loading file at the module level, the network device only loads the command line information of the specified business modules from the command line configuration file during startup. Command line information for other business modules remains stored in the configuration file, thus requiring only a small amount of command line information to be loaded into memory, thereby shortening device startup time. Simultaneously, since only the command line information of the specified business modules is retained in the device memory, the command tree in memory is smaller, reducing memory resource consumption and improving the device's cost-effectiveness. Reducing the size of the command tree also ensures that each command line can be parsed and executed quickly, improving command line parsing efficiency. Furthermore, this invention adds a command line management server to centrally manage all command lines. This server can automatically generate command line configuration files and command manuals according to certain rules and algorithms, separating command line registration from device operation, thereby facilitating the maintenance of the device command manual and reducing the investment in command manual revisions.
[0047] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0048] Please refer to Figure 1 This is a flowchart illustrating a command-line processing method provided in an embodiment of the present invention. It should be noted that the command-line processing method in this embodiment is not based on... Figure 1 The specific order described below is a limitation. It should be understood that in other embodiments, the order of some steps in the command line processing method of this invention can be interchanged according to actual needs, or some steps can be omitted or deleted. This command line processing method can be applied to network devices such as switches and routers. These network devices pre-store command line configuration files and command line loading files. The command line configuration files include command line information for each service module of the network device, and the command line loading files include module identifiers specifying the service modules. The following will discuss... Figure 1 The specific process shown will be explained in detail.
[0049] Step S101: When the network device starts up, obtain the module identifier of the specified service module in the command line loading file.
[0050] In this embodiment, the command-line loading file can be pre-generated and stored on the network device's disk. This command-line loading file includes module identifiers for specified service modules; that is, it describes, at the module level, which service modules the network device needs to use. The specified service modules can include commonly used modules (basic modules) of the network device and customized modules for actual use scenarios; the module identifier is the identification information of the service module, such as the module name.
[0051] When a network device starts up, it reads the command-line loading file saved on the disk and then obtains the module identifier of the specified business module recorded in the command-line loading file, such as the module name of the network device's commonly used modules and customized modules for actual use scenarios.
[0052] Step S102: Obtain the command line information of the specified business module from the command line configuration file according to the module identifier of the specified business module.
[0053] In this embodiment, the command-line configuration file can also be pre-generated and stored on the network device's disk. This configuration file includes command-line information for all service modules of the network device. After obtaining the module identifier of a specified service module from the command-line loading file, the network device searches the command-line configuration file based on that module identifier to obtain the command-line information for that specified service module.
[0054] Step S103: Load the command line information of the specified business module into memory to generate a memory command tree.
[0055] In this embodiment, after the network device obtains the command line information of a specified service module, it loads all the command line information belonging to that specified service module into memory and generates a command tree in memory, thus obtaining a memory command tree. Since only the command line information of some basic modules and customized modules is loaded into the memory command tree, and the commands of most service modules are still stored in the command line configuration files on the disk, the memory command tree is relatively small, occupies less memory resources, parses commands faster, and shortens the device startup time.
[0056] As can be seen, the command-line processing method provided in this embodiment of the invention, by pre-storing a command-line configuration file and a command-line loading file in the network device, wherein the command-line configuration file includes command-line information of each service module of the network device, and the command-line loading file includes a module identifier of a specified service module, when the network device starts, it obtains the module identifier of the specified service module from the command-line loading file, and obtains the command-line information of the specified service module from the command-line configuration file according to the module identifier of the specified service module, loads the command-line information of the specified service module into memory, and generates a memory command tree. By adding a command-line loading file to the network device, specifying which service module's command-line information to load at the module granularity, the network device only loads the command-line information of the specified service module from the command-line configuration file when it starts, while the command-line information of other service modules is still stored in the command-line configuration file. This achieves the goal of loading only a small amount of command-line information into memory, thus shortening the device startup time; at the same time, since only the command-line information of the specified service module is retained in the device memory, the command tree in memory is relatively small, reducing memory resource consumption and improving command-line parsing efficiency. Furthermore, by specifying the command line information for commonly used modules and customized modules for actual use cases in advance in the command line loading file, it is ensured that loading a small amount of command line information into the command tree in memory when the device starts up is sufficient to meet most application scenarios.
[0057] Optionally, the command-line configuration file is an XML (Extensible Markup Language) file, and the command-line information in the command-line configuration file is organized in a tree structure.
[0058] XML is a subset of Standard Generalized Markup Language (SGML), a markup language used to structure electronic documents. XML can be used to mark up data, define data types, and is a source language that allows users to define their own markup languages. It has advantages such as good extensibility, separation of content and form, adherence to strict syntax requirements, and good value retention.
[0059] Since the command-line configuration file is an XML file, and the command-line information in the file is stored in a tree structure, it is beneficial to find the command-line information and improves the search efficiency.
[0060] Alternatively, please refer to Figure 2To facilitate unified management of commands for all service modules within the network device, this embodiment of the invention deploys a command-line management server 200 in the network, with the network device 100 communicating with the command-line management server 200. The command-line configuration file can be generated by the command-line management server 200 based on the command-line information of each service module input by the user and sent to the network device 100; the command-line management server 200 can also generate a command manual for the network device 100 based on the command-line information of each service module input by the user.
[0061] For example, maintenance personnel for each business module log in to the command-line management server and, based on a specified device (e.g., network device 100), add, delete, modify, and query the command lines for each business module. Following the prompts from the command-line management server 200, they fill in the command-line information for each business module, including keywords, parameters, configuration mode, usage methods, precautions, and the index value of the command processing function. Each command line has a unique index value, used by the device software to execute the command line and determine the corresponding command processing function. This index value can be a string, named according to the module name plus the submodule name plus a brief description of the function. After all the command-line information for all business modules is filled in, the command-line management server 200 automatically generates two files: a command-line configuration file and a command manual. The command-line configuration file is an XML file that organizes the command-line information for all business modules into a tree structure (command tree) according to agreed-upon rules and algorithms, facilitating command-line retrieval. Simultaneously, by automatically generating the command manual for the specified device, maintenance of the command manual is facilitated, reducing the investment in revising the command manual.
[0062] As can be seen, by adding a command-line management server, the embodiments of the present invention can uniformly manage the commands of all business modules in the network device. It can generate tree-structured XML files and command manuals according to certain rules and algorithms, thereby separating command registration from the device and facilitating the maintenance of the device command manual.
[0063] Alternatively, please refer to Figure 3 The command line processing method provided in this embodiment of the invention may further include:
[0064] Step S301: When a user command is obtained, query the memory command tree to see if there is a target command line that matches the user command.
[0065] In this embodiment, when a user needs to manage and maintain a network device, they can enter commands on the network device's command-line interface. After the network device receives the user's command, it will query the memory command tree to determine whether there is a target command line that matches the user's command in the memory command tree.
[0066] In this embodiment, the command line information includes the command line and its associated information. The command line can be formed by combining several keywords in a certain order, with each keyword corresponding to a node in the command tree. The associated information of the command line can include parameters, configuration mode, usage method, precautions, and the index value of the command processing function. After receiving the command input by the user, the network device traverses the memory command tree and performs keyword matching between the user command and the command lines in the memory command tree. If a target command line matching the user command exists, step S302 is executed; otherwise, step S303 is executed.
[0067] Step S302: If a target command line matching the user command exists in the memory command tree, then the target command line is executed according to its association information.
[0068] In this embodiment, when the network device finds a target command line that matches the user's command in the memory command tree, it can execute the target command line according to the association information of the target command line and feed back the execution result to the user.
[0069] Step S303: If there is no target command line matching the user command in the memory command tree, then obtain the target command line matching the user command from the command line configuration file, and execute the target command line according to the association information of the target command line.
[0070] In this embodiment, when the network device does not find a target command line matching the user's command in the memory command tree, it indicates that the user is executing a command line that does not exist in the memory command tree. At this time, the network device will attempt to parse the XML file (command line configuration file) on the disk to obtain the target command line matching the user's command, and execute the target command line according to its association information, then return the execution result to the user. Since the content of the XML file is already stored according to the command tree structure, the designed algorithm can quickly parse the target command line from the XML file and load it into memory for execution, thereby reducing customer waiting time and improving user experience.
[0071] Optionally, since the command line's association information includes the index value of the corresponding command processing function, the network device also needs to use this index value to define the corresponding command processing function to facilitate indexing the corresponding command processing function when executing the command line. This command processing function is the function that actually implements the functionality corresponding to the command line.
[0072] In one implementation, the network device pre-stores the correspondence between index values and function addresses of command processing functions. The above-mentioned execution of the target command line based on the association information of the target command line may include: obtaining the function address of the command processing function corresponding to the target command line based on the index value and correspondence in the association information of the target command line; and calling the command processing function corresponding to the target command line based on the function address of the command processing function corresponding to the target command line.
[0073] In other words, when a network device executes a target command line based on the associated information of the target command line, it first finds the function address of the command processing function corresponding to the target command line based on the index value and correspondence of the command processing function corresponding to the target command line, and then calls the command processing function corresponding to the target command line based on the function address to execute the target command line and obtain the execution result.
[0074] As can be seen, in the command line processing method provided by the embodiments of the present invention, by adding the index value of the command processing function corresponding to the command line in the command line configuration file, and pre-storing the correspondence between the index value and the function address of the command processing function in the network device, when the network device executes the command line, the function address of the command processing function can be quickly indexed through the index value of the command processing function and the command processing function can be called, thereby completing the execution of the command line.
[0075] To perform the corresponding steps in the above embodiments and various possible methods, an implementation of a command-line processing device is given below. Please refer to... Figure 4 This is a functional block diagram of a command line processing device 600 provided in an embodiment of the present invention. It should be noted that the basic principle and technical effects of the command line processing device 600 provided in this embodiment are the same as those in the above embodiments. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above embodiments. The command line processing device 600 includes: an acquisition module 610, a search module 620, and a loading module 630.
[0076] The acquisition module 610 is used to acquire the module identifier of a specified service module in the command-line loading file when the network device starts up.
[0077] It is understood that the acquisition module 610 can perform the above step S101.
[0078] The lookup module 620 is used to retrieve the command-line information of a specified business module from the command-line configuration file based on the module identifier of the specified business module.
[0079] It is understood that the lookup module 620 can perform the above step S102.
[0080] The loading module 630 is used to load the command line information of the specified business module into memory and generate a memory command tree.
[0081] It is understood that the loading module 630 can perform the above step S103.
[0082] Optionally, the command-line configuration file can be generated by the command-line management server 200 based on the command-line information of each service module entered by the user and sent to the network device 100; the command-line management server 200 also generates a command manual for the network device 100 based on the command-line information of each service module entered by the user.
[0083] Optionally, the command-line configuration file is an XML file, and the command-line information in the command-line configuration file is organized in a tree structure.
[0084] Optionally, this command-line information includes the command line and its associated information. Please refer to [link / reference]. Figure 5 The command line processing device 600 further includes an execution module 640, which is used to query whether a target command line matching the user command exists in the memory command tree when a user command is obtained; if a target command line matching the user command exists in the memory command tree, the target command line is executed according to the association information of the target command line; if no target command line matching the user command exists in the memory command tree, the target command line matching the user command is obtained from the command line configuration file and executed according to the association information of the target command line.
[0085] It is understood that the execution module 640 can execute the above steps S301 to S303.
[0086] Optionally, the network device pre-stores the mapping between index values and function addresses of command processing functions, and the command line association information includes the index value of the command processing function corresponding to the command line. Specifically, the execution module 640 is used to obtain the function address of the command processing function corresponding to the target command line based on the index value and mapping in the target command line association information; and to call the command processing function corresponding to the target command line based on the function address of the command processing function corresponding to the target command line.
[0087] As can be seen, the command-line processing device provided in this embodiment of the invention includes an acquisition module, a search module, and a loading module. The acquisition module is used to acquire the module identifier of a specified service module in the command-line loading file when the network device starts up. The search module is used to acquire the command-line information of the specified service module from the command-line configuration file according to the module identifier of the specified service module. The loading module is used to load the command-line information of the specified service module into memory and generate a memory command tree. By adding a command-line loading file to the network device, specifying which service module's command-line information to load at the module granularity, the network device only loads the command-line information of the specified service module from the command-line configuration file when it starts up. The command-line information of other service modules is still stored in the command-line configuration file. This achieves the goal of loading only a small amount of command-line information into memory, thus shortening the device startup time. At the same time, since only the command-line information of the specified service module is retained in the device memory, the command tree in memory is relatively small, reducing memory resource consumption and improving command-line parsing efficiency. Furthermore, by specifying the command-line information of commonly used modules and customized modules for actual use scenarios in advance in the command-line loading file, it is ensured that loading a small amount of command-line information into the memory command tree when the device starts up is sufficient to meet most application scenarios.
[0088] Please refer to Figure 6 This is a block diagram of a network device 100 provided in an embodiment of the present invention. The network device 100 includes a memory 110, a processor 120, and a communication module 130. The memory 110, processor 120, and communication module 130 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.
[0089] The memory 110 is used to store programs or data. The memory 110 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0090] The processor 120 is used to read / write data or programs stored in the memory 110 and perform corresponding functions. For example, when a computer program stored in the memory 110 is executed by the processor 120, the command-line processing method disclosed in the above embodiments can be implemented.
[0091] The communication module 130 is used to establish a communication connection between the network device 100 and other devices through the network, and to send and receive data through the network.
[0092] It should be understood that, Figure 6 The structure shown is only a schematic diagram of the network device 100. The network device 100 may also include components that are larger than... Figure 6 The more or fewer components shown, or having the same Figure 6 The different configurations shown. Figure 6 The components shown can be implemented using hardware, software, or a combination thereof.
[0093] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor 120, implements the command-line processing method disclosed in the above embodiments.
[0094] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0095] In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0096] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0097] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A command-line processing method, characterized in that, The method is applied to network devices, wherein the network devices pre-store command-line configuration files and command-line loading files. The command-line configuration files include command-line information for each service module of the network device, and the command-line loading files include module identifiers specifying the service modules. When the network device starts up, obtain the module identifier of the specified service module in the command-line loading file; Based on the module identifier of the specified business module, obtain the command line information of the specified business module from the command line configuration file; The command line information of the specified business module is loaded into memory to generate a memory command tree.
2. The command line processing method according to claim 1, characterized in that, The network device is communicatively connected to the command-line management server; the command-line configuration file is generated by the command-line management server based on the command-line information of each business module input by the user and sent to the network device. The command-line management server also generates a command manual for the network device based on the command-line information of each business module entered by the user.
3. The command line processing method according to claim 1, characterized in that, The command line information includes the command line and its associated information; the method further includes: When a user command is obtained, the system queries the memory command tree to see if a target command line matching the user command exists. If a target command line matching the user command exists in the memory command tree, the target command line is executed according to its association information.
4. The command line processing method according to claim 3, characterized in that, The method further includes: If no target command line matching the user command exists in the memory command tree, the target command line matching the user command is obtained from the command line configuration file, and the target command line is executed according to the association information of the target command line.
5. The command line processing method according to claim 3 or 4, characterized in that, The network device pre-stores the correspondence between the index values and function addresses of command processing functions, and the associated information of the command line includes the index value of the command processing function corresponding to the command line; executing the target command line according to the associated information of the target command line includes: Based on the index value in the association information of the target command line and the correspondence, obtain the function address of the command processing function corresponding to the target command line; The command processing function corresponding to the target command line is called based on its function address.
6. The command line processing method according to any one of claims 1-4, characterized in that, The command-line configuration file is an XML file, and the command-line information in the command-line configuration file is organized in a tree structure.
7. A command-line processing device, characterized in that, Applied to network devices, the network devices pre-store command-line configuration files and command-line loading files. The command-line configuration files include command-line information for each service module of the network device, and the command-line loading files include module identifiers specifying the service modules. The device includes: The acquisition module is used to acquire the module identifier of a specified service module in the command-line loading file when the network device starts up; The lookup module is used to retrieve the command-line information of the specified business module from the command-line configuration file based on the module identifier of the specified business module. The loading module is used to load the command line information of the specified business module into memory and generate a memory command tree.
8. The command line processing device according to claim 7, characterized in that, The command line information includes the command line and its associated information; the device further includes: The execution module is used to, when a user command is obtained, query whether there is a target command line matching the user command in the memory command tree; if there is a target command line matching the user command in the memory command tree, execute the target command line according to the association information of the target command line; if there is no target command line matching the user command in the memory command tree, obtain the target command line matching the user command from the command line configuration file, and execute the target command line according to the association information of the target command line.
9. A network device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the command-line processing method as described in any one of claims 1-6.
10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the steps of the command-line processing method as described in any one of claims 1-6.
Citation Information
Patent Citations
Method and device for converting network configuration protocol response message into command line
CN102447585A
Methods and systems for trusted unknown malware detection and classification in linux cloud environments
WO2022101909A1