[go: up one dir, main page]

CN110908729B - A method of processing command line output information based on regular matching - Google Patents

A method of processing command line output information based on regular matching Download PDF

Info

Publication number
CN110908729B
CN110908729B CN201910968837.8A CN201910968837A CN110908729B CN 110908729 B CN110908729 B CN 110908729B CN 201910968837 A CN201910968837 A CN 201910968837A CN 110908729 B CN110908729 B CN 110908729B
Authority
CN
China
Prior art keywords
result
data
command line
command
text
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910968837.8A
Other languages
Chinese (zh)
Other versions
CN110908729A (en
Inventor
陈礼
范渊
黄进
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ningbo Ningshu Security Technology Co.,Ltd.
Original Assignee
DBAPPSecurity Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by DBAPPSecurity Co Ltd filed Critical DBAPPSecurity Co Ltd
Priority to CN201910968837.8A priority Critical patent/CN110908729B/en
Publication of CN110908729A publication Critical patent/CN110908729A/en
Application granted granted Critical
Publication of CN110908729B publication Critical patent/CN110908729B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • G06F9/4451User profiles; Roaming
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a command line output information processing method based on regular matching, which solves the four problems by combing the relationship among the command line, the regular analysis rule and the final data result, stripping the variable service in the command line mode, and converting the service into a specific fixed service and variable file configuration. The invention can automatically acquire and analyze the basic information of the operating system (network equipment) to generate customizable result data, and a user does not need to manually input the acquired data; the invention has good compatibility treatment for the difference of different operating systems and network equipment; the speed of acquiring information by the original command line is optimized, and the space resources required by running the command are reduced. For business support of a new system (equipment), a user only needs to modify a configuration file, so that too many programs are not required to be changed, and development time and subsequent maintenance work time are reduced.

Description

基于正则匹配的命令行输出信息处理方法A method of processing command line output information based on regular matching

技术领域technical field

本发明涉及一种命令行输出信息处理方法,具体涉及一种基于正则匹配的命令行输出信息处理方法。The invention relates to a command line output information processing method, in particular to a command line output information processing method based on regular matching.

背景技术Background technique

运行命令主要是DOS操作系统的运行方式。无论windows系统还是Linux系统,都支持运行命令方式来获取系统的运行结果信息。特别是各种网络设备,厂商提供的设备交互接口基本包括命令模式。The run command is mainly the operation mode of the DOS operating system. Regardless of the windows system or the Linux system, both support the running command mode to obtain the running result information of the system. Especially for various network devices, the device interaction interface provided by the manufacturer basically includes the command mode.

SHH,telnet等工具支持远程运行命令,在客户端上展示远程系统的运行结果。Tools such as SHH and telnet support remote running commands and display the running results of the remote system on the client.

这类工具一般由用户手动输入一条远程命令,当远程系统执行命令后,由显示端输出命令运行结果。This type of tool generally requires the user to manually input a remote command, and when the remote system executes the command, the display terminal outputs the command execution result.

命令行方式可获取操作系统(网络设备)的基础配置信息。在网络环境下,远程命令行方式是常用的获取操作系统基础配置的方法。The command line method can obtain the basic configuration information of the operating system (network device). In a network environment, the remote command line method is a commonly used method to obtain the basic configuration of the operating system.

这种方法有以下缺点:This approach has the following disadvantages:

1、用户需手动输入每条命令行,保存原始文本数据。2、不同的系统或者设备,同样的数据结果所需要的命令行不同,原始文本数据也有差异。3、用户最终结果数据随着具体业务变化。4、基于第二种缺点,自动化程序面临如何以最大工效实现对新系统和设备的支持问题。1. The user needs to manually input each command line to save the original text data. 2. Different systems or devices require different command lines for the same data results, and the original text data is also different. 3. The user's final result data changes with the specific business. 4. Based on the second shortcoming, the automation program is faced with the problem of how to achieve support for new systems and equipment with maximum ergonomics.

因此,需要对现有技术进行改进。Therefore, it is necessary to improve the prior art.

发明内容Contents of the invention

本发明要解决的技术问题是提供一种高效的基于正则匹配的命令行输出信息处理方法。The technical problem to be solved by the present invention is to provide an efficient regular matching-based command line output information processing method.

为解决上述技术问题,本发明提供一种基于正则匹配的命令行输出信息处理方法,包括以下步骤:In order to solve the above technical problems, the present invention provides a method for processing command line output information based on regular matching, comprising the following steps:

S1、根设置命令行列表文件、命令行正则表达式匹配表和命令行结果匹配表;执行步骤S2;S1, the root sets the command line list file, the command line regular expression matching table and the command line result matching table; execute step S2;

命令行列表文件中的命令行列表数据包括:命令行唯一辨识ID、命令行的名字、命令行的具体文本命令、等待命令失效时间;The command line list data in the command line list file includes: the unique identification ID of the command line, the name of the command line, the specific text command of the command line, and the waiting time for the command to expire;

命令行正则表达式匹配表中的命令行正则表达式匹配表数据包括:结果项名、命令行唯一辨识ID、结果项默认结果值、程序方法辨识符号、程序参数列表、正则表达式、中间数据标识名;The command line regular expression matching table data in the command line regular expression matching table includes: result item name, command line unique identification ID, result item default result value, program method identification symbol, program parameter list, regular expression, intermediate data identification name;

命令行结果匹配表中的命令行结果匹配表数据包括:结果项名、描述、结果表达格式、结果是否展示标志;The command line result matching table data in the command line result matching table includes: result item name, description, result expression format, and whether the result is displayed or not;

S2、循环遍历执行命令行列表文件内的命令行的具体文本命令,得到命令执行的文本结果;执行步骤S3;S2, cyclically traversing and executing the specific text commands of the command lines in the command line list file, to obtain the text results of command execution; execute step S3;

每条命令行列表数据和命令执行的文本结果作为原始结果数据,保存至原始数据集合;The list data of each command line and the text result of command execution are saved to the original data collection as the original result data;

每条原始结果数据包括命令行唯一辨识ID,命令行的名字,命令行的具体文本,命令执行的文本结果;Each original result data includes the unique identification ID of the command line, the name of the command line, the specific text of the command line, and the text result of command execution;

S3、提取命令行结果匹配表中的数据,创建结果获取循环列表,通过其中的单条数据的结果项名来查找命令行正则表达式匹配表数据对应的命令行唯一辨识ID、正则表达式、程序方法辨识符号、程序参数列表、结果项默认结果值和中间数据标识名;S3. Extract the data in the command line result matching table, create a result acquisition circular list, and find the command line unique identification ID, regular expression, and program corresponding to the command line regular expression matching table data through the result item name of a single piece of data. method identifier, program parameter list, result item default result value and intermediate data identification name;

根据命令行唯一辨识ID查找S2中的原始结果数据,得到S2中的对应命令执行的文本结果;如果能找到相应的原始结果数据则执行步骤S4;否则,获取循环列表中下一项命令行唯一辨识ID重新检测;Find the original result data in S2 according to the unique identification ID of the command line, and obtain the text result of the corresponding command execution in S2; if the corresponding original result data can be found, execute step S4; otherwise, obtain the unique command line of the next item in the loop list Identification ID retesting;

S4、根据步骤S3中的程序方法辨识符号、程序参数列表、正则表达式来构造S3中得到原始数据对应的处理方法,根据该处理方法来解析处理原始结果数据中的命令执行的文本结果,获取解析处理数据,根据获取循环列表的结果是否展示标志来判断解析处理数据是否是最终结果;如果是最终结果,循环列表删除对应结果项名的对应结果项,并把解析处理数据保存至最终数据中,然后执行步骤S5;S4, construct the processing method corresponding to the original data obtained in S3 according to the program method identification symbol, program parameter list, and regular expression in step S3, analyze and process the text result of the command execution in the original result data according to the processing method, and obtain Parsing and processing data, judging whether the parsing and processing data is the final result according to whether the result of obtaining the loop list displays a flag; if it is the final result, the loop list deletes the corresponding result item corresponding to the result item name, and saves the parsing and processing data to the final data , and then execute step S5;

S5、根据相应的中间数据标识名,判断步骤S4得到的最终结果是否可以作为结果获取循环列表中的其它结果匹配项的原始数据,如果中间数据标识名不为空,执行步骤S6;如果中间数据标识名为空,执行步骤S7;S5. According to the corresponding intermediate data identification name, judge whether the final result obtained in step S4 can be used as a result to obtain the original data of other result matching items in the circular list, if the intermediate data identification name is not empty, perform step S6; if the intermediate data If the identification name is empty, execute step S7;

S6、将最终数据的解析处理数据和相应的中间数据标识名作为中间数据标识名保存到原始数据中;执行步骤S7;S6. Save the analysis and processing data of the final data and the corresponding intermediate data identification name as the intermediate data identification name in the original data; execute step S7;

S7、获取结果获取循环列表中未处理的结果项;执行步骤S8;S7. Acquiring the results Obtain unprocessed result items in the circular list; execute step S8;

S8、判断结果获取循环列表内是否被全部处理,未处理完数据跳转至步骤S3;处理完则执行步骤S9;S8. Judging whether all the result acquisition circular lists have been processed, jump to step S3 for unprocessed data; execute step S9 after processing;

S9、通过命令行结果匹配表的每项数据的结果是否展示标志,来判断该项数据是否为输出数据;如果是输出数据,通过结果项名查找最终数据的解析处理数据;根据结果表达式重新格式化解析处理数据,得到每项数据新的最终结果。S9. Determine whether the item data is output data by checking whether the result of each item of data in the command line result matching table displays a flag; if it is output data, search for the analysis and processing data of the final data through the result item name; Format, analyze and process the data to obtain a new final result for each item of data.

作为对本发明基于正则匹配的命令行输出信息处理方法的改进:As an improvement to the regular matching-based command line output information processing method of the present invention:

在步骤S2中:如果执行单条命令花费的时间超过等待命令失效时间,中断命令,将空文本作为命令执行的文本结果;如果执行单条命令花费的时间不超过等待命令失效时间,以结果文本作为命令执行的文本结果。In step S2: if the time spent executing a single command exceeds the waiting command expiration time, interrupt the command, and use empty text as the text result of the command execution; if the time spent executing a single command does not exceed the waiting command expiration time, use the result text as the command The text result of the execution.

作为对本发明基于正则匹配的命令行输出信息处理方法的进一步改进:As a further improvement to the regular matching-based command line output information processing method of the present invention:

在步骤S4中:如果解析处理过程中缺少数据,则查找原始结果数据中的中间结果数据集合,如果未找到中间结果数据,执行步骤S7。In step S4: if data is missing during the parsing process, search for the intermediate result data set in the original result data, and if no intermediate result data is found, execute step S7.

作为对本发明基于正则匹配的命令行输出信息处理方法的进一步改进:As a further improvement to the regular matching-based command line output information processing method of the present invention:

可变化的配置文件:命令行列表、命令行正则表达式匹配表、命令结果匹配表。Changeable configuration files: command line list, command line regular expression matching table, command result matching table.

作为对本发明基于正则匹配的命令行输出信息处理方法的进一步改进:As a further improvement to the regular matching-based command line output information processing method of the present invention:

命令行正则表达式匹配表和结果命令行匹配表的表示形式为XML文件、文本文件、JSON格式文件或者数据库文件方式。The representation form of the command line regular expression matching table and the result command line matching table is an XML file, a text file, a JSON format file or a database file.

本发明基于正则匹配的命令行输出信息处理方法的技术优势为:The technical advantages of the command line output information processing method based on regular matching in the present invention are:

本发明通过梳理命令行,正则解析规则,最终数据结果的三者之间的关系,剥离命令行方式的中的变化性业务,将该业务转化为特定的固定业务和可变文件配置,解决了上述四个问题。The present invention solves the problem by sorting out the relationship between the command line, regular parsing rules, and final data results, stripping off the variable business in the command line mode, and transforming the business into a specific fixed business and variable file configuration. the above four questions.

本发明可自动化获取并分析操作系统(网络设备)的基本信息生成可定制结果数据,用户不再需要手动输入获取数据;该发明对不同的操作系统和网络设备的差异性有很好的兼容处理;优化了原本命令行获取信息的速度,减少了运行命令所需的空间资源。对于新系统(设备)的业务支持,用户只需要修改配置文件,不需要变动太多程序,减少开发时间和后续维护工作时间。The invention can automatically obtain and analyze the basic information of the operating system (network equipment) to generate customizable result data, and the user no longer needs to manually input and obtain data; the invention has good compatibility with the differences of different operating systems and network equipment ; Optimize the speed of obtaining information from the original command line, and reduce the space resources required to run the command. For the business support of the new system (equipment), the user only needs to modify the configuration file without changing too many programs, reducing the development time and subsequent maintenance work time.

附图说明Description of drawings

下面结合附图对本发明的具体实施方式作进一步详细说明。The specific implementation manners of the present invention will be described in further detail below in conjunction with the accompanying drawings.

图1为本发明基于正则匹配的命令行输出信息处理方法的流程示意图。FIG. 1 is a schematic flowchart of a method for processing command line output information based on regular matching in the present invention.

具体实施方式Detailed ways

下面结合具体实施例对本发明进行进一步描述,但本发明的保护范围并不仅限于此。The present invention will be further described below in conjunction with specific examples, but the protection scope of the present invention is not limited thereto.

实施例1、基于正则匹配的命令行输出信息处理方法,如图1所示,包括以下步骤:Embodiment 1, the command line output information processing method based on regular matching, as shown in Figure 1, comprises the following steps:

S1、根据对应系统(设备)需求制作命令行列表文件、命令行正则表达式匹配表和命令行结果匹配表。在步骤S1中,三张表的数据需要人为先设置后,才可进行S2步骤。S1. Make a command line list file, a command line regular expression matching table, and a command line result matching table according to the requirements of the corresponding system (equipment). In step S1, the data of the three tables need to be manually set before step S2 can be performed.

每张表内部的每条数据包含属性如下:Each piece of data in each table contains the following attributes:

命令行列表文件中的命令行列表数据:命令行唯一辨识ID、命令行的名字、命令行的具体文本命令、等待命令失效时间。The command line list data in the command line list file: the unique identification ID of the command line, the name of the command line, the specific text command of the command line, and the waiting time for the command to expire.

命令行列表文件的命令行列表数据只在S2步骤中起作用,其作用如下:The command line list data of the command line list file only works in the S2 step, and its functions are as follows:

命令行唯一标识ID:以增量的方式产生,和命令行正则表达式匹配表的命令行唯一标识ID相对应;执行步骤S2后,和文本结果一同保存为原始结果数据。命令行列表文件的单条数据对应多条命令行正则表达式匹配表数据。Command line unique ID: generated incrementally, corresponding to the command line unique ID of the command line regular expression matching table; after step S2 is executed, it is saved together with the text result as the original result data. A single piece of data in the command line list file corresponds to multiple pieces of command line regular expression matching table data.

命令行的名字:定义命令行的功能类型。执行步骤S2后和文本结果一起保存为原始结果数据。命令行名字不同,命令执行方式也不同。比如登录系统,需要输入用户名和密码;获取系统配置功能需要输入命令。The name of the command line: defines the function type of the command line. After step S2 is executed, it is saved together with the text result as the original result data. Command line names are different, and command execution methods are also different. For example, to log in to the system, you need to enter a user name and password; to obtain system configuration functions, you need to enter commands.

命令行的具体文本命令:命令行的文本表示。执行步骤S2后和文本结果一起保存为原始结果数据。Concrete textual command of the command line: the textual representation of the command line. After step S2 is executed, it is saved together with the text result as the original result data.

等待命令失效时间:设置步骤S2中等待命令行运行的最长时间。只作用于命令执行过程,不作为原始结果数据保存。Waiting command expiration time: set the maximum time for waiting for the command line to run in step S2. It only applies to the command execution process and is not saved as the original result data.

命令行正则表达式匹配表中的命令行正则表达式匹配表数据:结果项名、命令行唯一辨识ID、结果项默认结果值、程序方法辨识符号、程序参数列表、正则表达式、中间数据标识名。Command line regular expression matching table data in the command line regular expression matching table: result item name, command line unique identification ID, result item default result value, program method identification symbol, program parameter list, regular expression, intermediate data identifier name.

命令行正则表达式匹配表的各属性在步骤S3至S8中起作用,其作用如下:Each attribute of the command line regular expression matching table works in steps S3 to S8, and its effect is as follows:

结果项名:和命令行结果匹配表内的结果项名对应。命令行结果匹配表内的结果项名集合是命令行正则表达式匹配表的结果项名集合的子集。结果项名唯一。Result item name: corresponds to the result item name in the command line result matching table. The set of result item names in the command line result match table is a subset of the result item name set in the command line regular expression match table. Result item names are unique.

命令行唯一辨识ID:和命令行列表文件的命令行唯一辨识ID对应。通过该属性必能找到一条命令行列表数据。Command line unique identification ID: corresponds to the command line unique identification ID of the command line list file. A command line list data must be found through this property.

结果项默认结果值:保存默认处理结果数据。当解析原始数据未获得结果时使用。Result item default result value: save the default processing result data. Used when parsing raw data yields no results.

程序方法辨识符号:不同的正则表达式有不同的处理方法,辨识符号用于选择处理方法。Program method identification symbol: Different regular expressions have different processing methods, and identification symbols are used to select the processing method.

程序参数列表:使用正则表达式处理数据时传入的参数。不同的处理方法有不同的参数(参数类型,数目都不同),和程序方法辨识符号、正则表达式一同确定原始数据处理方法。Program parameter list: parameters passed in when using regular expressions to process data. Different processing methods have different parameters (parameter types and numbers are different), which determine the original data processing method together with the program method identification symbol and regular expression.

正则表达式:处理原始数据使用的正则表达式,和程序参数列表和程序方法辨识符号一同确定原始数据处理方法。Regular expression: The regular expression used to process raw data, together with the program parameter list and program method identifier, determines the raw data processing method.

中间数据标识名:中间数据标识名不为空时,处理完的数据可以作为中间数据保存。通过中间数据标识名来区别中间数据。中间数据标识名唯一。Intermediate data identification name: When the intermediate data identification name is not empty, the processed data can be saved as intermediate data. The intermediate data is distinguished by the intermediate data identification name. The intermediate data identification name is unique.

命令行列表文件的数据依据命令行列表数据制作。The data of the command line list file is created based on the command line list data.

命令行结果匹配表中的命令行结果匹配表数据:结果项名、描述、结果表达格式、结果是否展示标志。Command line result matching table data in the command line result matching table: result item name, description, result expression format, and whether to display the flag.

命令行结果匹配表的各属性在步骤S3至S9中起作用,其作用如下:Each attribute of the command line result matching table plays a role in steps S3 to S9, and its effect is as follows:

命令行结果匹配表的各属性作用如下:The functions of each attribute of the command line result matching table are as follows:

结果项名:和命令行正则表达式匹配表内的结果项名对应。如果某条结果依赖其他检测结果,命令行结果匹配表需要加入依赖的结果项名。Result item name: corresponds to the result item name in the command line regular expression matching table. If a certain result depends on other detection results, the command line result matching table needs to add the dependent result item name.

描述:结果数据的含义描述。Description: Description of the meaning of the result data.

结果表达式:结果数据输出时使用的数据格式。Result expression: the data format used when the result data is output.

结果是否展示标志:部分结果作为其他结果的中间结果,通过该标志来判断是否需要输出。Whether the result shows a flag: Some results are used as intermediate results of other results, and the flag is used to determine whether output is required.

命令行结果匹配表的结果是否展示标志和命令行正则表达式匹配表的中间数据标识名没有关系,前者用于最终结果的输出,后者用于判断处理后的命令结果是否可以作为中间数据。Whether the result of the command line result matching table shows the flag has nothing to do with the intermediate data identification name of the command line regular expression matching table. The former is used for the output of the final result, and the latter is used to judge whether the processed command result can be used as intermediate data.

S2、循环遍历执行命令行列表文件内的每条命令(命令行的具体文本命令属性保存),得到命令执行的文本结果。如果执行单条命令花费的时间超过等待命令失效时间,中断命令,将空文本作为命令执行的文本结果;如果执行单条命令花费的时间不超过等待命令失效时间,以结果文本作为命令执行的文本结果。S2. Cycle through and execute each command in the command line list file (the specific text command attribute of the command line is saved), and obtain the text result of the command execution. If the time spent executing a single command exceeds the waiting command expiration time, the command is interrupted, and empty text is used as the text result of the command execution; if the time spent executing a single command does not exceed the waiting command expiration time, the result text is used as the text result of the command execution.

每条命令行列表数据和命令执行的文本结果作为原始结果数据,保存至原始数据集合。原始数据集合在步骤S3至S8中起作用。The list data of each command line and the text result of command execution are saved to the original data collection as the original result data. The raw data set works in steps S3 to S8.

每条原始结果数据包括命令行唯一辨识ID,命令行的名字,命令行的具体文本,命令执行的文本结果,不包括等待命令失效时间。Each piece of original result data includes the unique identification ID of the command line, the name of the command line, the specific text of the command line, and the text result of the command execution, excluding the waiting time for the command to expire.

S3、提取命令行结果匹配表中的数据,创建结果获取循环列表(相当于命令行结果匹配表的副表)。通过该副表中的单条数据的结果项名,查找命令行正则表达式匹配表数据对应的命令行唯一辨识ID、正则表达式、程序方法辨识符号、程序参数列表、结果项默认结果值和中间数据标识名。S2过程中已得到所有命令执行结果,S3由命令行结果匹配表反向来确定每条结果对应的执行结果。S3. Extract the data in the command line result matching table, and create a result acquisition circular list (equivalent to a sub-table of the command line result matching table). Through the result item name of a single piece of data in the sub-table, find the command line unique identification ID, regular expression, program method identification symbol, program parameter list, result item default result value and intermediate corresponding to the command line regular expression matching table data The data identifier name. In the process of S2, all command execution results have been obtained, and in S3, the execution result corresponding to each result is determined in reverse by the command line result matching table.

根据命令行唯一辨识ID查找S2中的原始结果数据,得到S2中的对应命令执行的文本结果。如果可以找到相应的原始结果数据则执行步骤S4;否则,获取循环列表中下一项的数据(命令行唯一辨识ID)重新检测;Search the original result data in S2 according to the unique identification ID of the command line, and obtain the text result of the execution of the corresponding command in S2. If the corresponding original result data can be found, execute step S4; otherwise, obtain the data of the next item in the circular list (command line unique identification ID) and retest;

S4、根据S3中确定的程序方法辨识符号、程序参数列表、正则表达式来构造S3中得到原始数据对应的处理方法,根据该处理方法来解析处理原始结果数据中的命令执行的文本结果,获取解析处理数据。根据获取循环列表的结果是否展示标志来判断解析处理数据是否是最终结果。如果是最终结果,循环列表删除对应结果项名的对应结果项,并把解析处理数据保存至最终数据中,然后执行步骤S5;S4. Construct the processing method corresponding to the original data obtained in S3 according to the program method identification symbol, program parameter list, and regular expression determined in S3, analyze and process the text result of the command execution in the original result data according to the processing method, and obtain Parse and process data. Judging whether the parsing and processing data is the final result according to whether the result of obtaining the circular list displays a flag. If it is the final result, the circular list deletes the corresponding result item corresponding to the result item name, and saves the parsing and processing data into the final data, and then executes step S5;

步骤S3中确定方法,参数,以及运行的结果,s4中通过方法参数模板构建具体方法来处理S3中结果对应的原始数据。In step S3, the method, parameters, and running results are determined, and in s4, a specific method is constructed through the method parameter template to process the original data corresponding to the result in S3.

如果解析处理过程中缺少数据,比如缺少解析所需的中间数据标识名(解析依赖其他命令执行结果,而该结果未轮到解析处理),查找原始结果数据中的中间结果数据集合,如果未找到中间结果数据,执行步骤S7。If there is a lack of data during the parsing process, such as the lack of intermediate data identification names required for parsing (parsing depends on the execution results of other commands, and the results are not yet in the parsing process), look for the intermediate result data set in the original result data, if not found Intermediate result data, go to step S7.

最终数据包括:结果项名和解析处理数据。The final data includes: result item name and parsing and processing data.

S5、根据中间数据标识名,判断步骤S4得到的最终结果是否可以作为结果获取循环列表中的其它结果匹配项的原始数据,如果中间数据标识名不为空,执行步骤S6;如果中间数据标识名为空,执行步骤S7;S5. According to the intermediate data identification name, judge whether the final result obtained in step S4 can be used as a result to obtain the original data of other result matching items in the circular list, if the intermediate data identification name is not empty, perform step S6; if the intermediate data identification name is empty, go to step S7;

S6、将最终数据的解析处理数据和相应的中间数据标识名作为中间数据标识名保存到原始数据中;S6. Saving the analysis and processing data of the final data and the corresponding intermediate data identification name into the original data as the intermediate data identification name;

原始数据集合分为两部分,一部分是S1步骤生成的原始结果数据,另一部分是中间结果数据。The original data set is divided into two parts, one part is the original result data generated by the S1 step, and the other part is the intermediate result data.

中间结果数据包含中间数据标识名和步骤S4中的解析处理数据。中间结果数据作为参数被部分解析过程使用。The intermediate result data includes the identification name of the intermediate data and the parsing and processing data in step S4. Intermediate result data are used as parameters by the partial parsing process.

S7、获取结果获取循环列表中未处理的结果项(已处理的结果项已在步骤S4移除);S7. Obtaining the result obtains the unprocessed result item in the circular list (the processed result item has been removed in step S4);

S8、判断结果获取循环列表内是否被全部处理(列表为空),未处理完数据(列表不为空)跳转至步骤S3;处理完则执行步骤S9;S8. Judging whether the result acquisition cycle list has been completely processed (the list is empty), and the unprocessed data (the list is not empty) jumps to step S3; after processing, execute step S9;

S9、通过命令行结果匹配表的每项数据的结果是否展示标志,来判断该项数据是否为输出数据。如果是输出数据,通过结果项名查找最终数据的解析处理数据。根据结果表达式重新格式化解析处理数据,得到每项数据新的最终结果。S9. Determine whether the item of data is output data according to whether the result of each item of data in the command line result matching table displays a flag. If it is output data, find the analysis and processing data of the final data through the result item name. Reformat, analyze and process data according to the result expression, and obtain a new final result for each item of data.

可变化的配置文件:命令行列表、命令行正则表达式匹配表、命令结果匹配表。Changeable configuration files: command line list, command line regular expression matching table, command result matching table.

命令行正则表达式匹配表和结果命令行匹配表的内部具体数据格式可变化。命令行正则表达式匹配表和结果命令行匹配表的表示形式也可不同,比如XML文件,文本文件,JSON格式文件,或者数据库文件方式。The internal specific data format of the command line regular expression matching table and the result command line matching table may vary. The representation forms of the command line regular expression matching table and the result command line matching table may also be different, such as XML files, text files, JSON format files, or database file formats.

最后,还需要注意的是,以上列举的仅是本发明的若干个具体实施例。显然,本发明不限于以上实施例,还可以有许多变形。本领域的普通技术人员能从本发明公开的内容直接导出或联想到的所有变形,均应认为是本发明的保护范围。Finally, it should be noted that the above examples are only some specific embodiments of the present invention. Obviously, the present invention is not limited to the above embodiments, and many variations are possible. All deformations that can be directly derived or associated by those skilled in the art from the content disclosed in the present invention should be considered as the protection scope of the present invention.

Claims (4)

1. The command line output information processing method based on regular matching is characterized by comprising the following steps of: the method comprises the following steps:
s1, setting a command line list file, a command line regular expression matching table and a command line result matching table by a root; executing the step S2;
the command rank table data in the command rank table file includes: the unique identification ID of the command line, the name of the command line, the specific text command of the command line and the waiting time of the command failure;
the command line regular expression matching table data in the command line regular expression matching table comprises: the method comprises the steps of a result item name, a command line unique identification ID, a result item default result value, a program method identification symbol, a program parameter list, a regular expression and an intermediate data identification name;
the command line result matching table data in the command line result matching table includes: a result item name, description, result expression format, and whether a result shows a flag;
s2, circularly traversing specific text commands of command lines in the command line list file to obtain a text result of command execution; executing the step S3;
each command list data and the text result of command execution are used as original result data and stored into an original data set;
each piece of original result data comprises a unique identification ID of a command line, a name of the command line, a specific text of the command line and a text result of command execution;
s3, extracting data in the command line result matching table, creating a result acquisition circulation list, and searching a command line unique identification ID, a regular expression, a program method identification symbol, a program parameter list, a result item default result value and an intermediate data identification name corresponding to the command line regular expression matching table data through the result item name of single data in the command line result matching table;
searching the original result data in the S2 according to the unique identification ID of the command line to obtain a text result executed by the corresponding command in the S2; if the corresponding original result data can be found, executing step S4; otherwise, acquiring the unique identification ID of the next command line in the circulation list for re-detection;
s4, constructing a processing method corresponding to the original data obtained in the step S3 according to the program method identification symbol, the program parameter list and the regular expression in the step S3, analyzing and processing a text result executed by a command in the original result data according to the processing method, acquiring analysis processing data, and judging whether the analysis processing data is a final result according to whether a result of acquiring the circulation list shows a sign or not; if the result is the final result, deleting the corresponding result item corresponding to the result item name by the circulation list, storing the analysis processing data into the final data, and then executing the step S5;
s5, judging whether the final result obtained in the step S4 can be used as a result to obtain the original data of other result matching items in the circulation list according to the corresponding intermediate data identification name, and executing the step S6 if the intermediate data identification name is not null; if the intermediate data identification name is empty, executing a step S7;
s6, the analysis processing data of the final data and the corresponding intermediate data identification names are used as the intermediate data identification names to be stored in the original data; executing step S7;
s7, acquiring unprocessed result items in the result acquisition circulation list; executing step S8;
s8, judging whether all the data in the result acquisition circulation list are processed or not, and jumping the unprocessed data to the step S3; executing step S9 after the processing is finished;
s9, judging whether the item of data is output data or not through whether the result of each item of data of the command line result matching table shows a sign or not; if the data is output data, searching analysis processing data of the final data through a result item name; and reformatting the analysis processing data according to the result expression to obtain a new final result of each item of data.
2. The regular matching-based command line output information processing method according to claim 1, wherein:
in step S2: if the time spent executing the single command exceeds the waiting command failure time, interrupting the command, and taking the empty text as a text result of command execution; if the time spent executing a single command does not exceed the waiting command expiration time, the result text is taken as the text result of the command execution.
3. The regular matching-based command line output information processing method according to claim 2, wherein:
in step S4: if the data is missing in the parsing process, searching for an intermediate result data set in the original result data, and if the intermediate result data is not found, executing step S7.
4. The regular matching-based command line output information processing method as claimed in claim 3, wherein: the internal specific data formats of the command line regular expression matching table and the result command line matching table can be changed, and the representation forms are xml files, text files, json files or database file modes.
CN201910968837.8A 2019-10-12 2019-10-12 A method of processing command line output information based on regular matching Active CN110908729B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910968837.8A CN110908729B (en) 2019-10-12 2019-10-12 A method of processing command line output information based on regular matching

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910968837.8A CN110908729B (en) 2019-10-12 2019-10-12 A method of processing command line output information based on regular matching

Publications (2)

Publication Number Publication Date
CN110908729A CN110908729A (en) 2020-03-24
CN110908729B true CN110908729B (en) 2023-05-23

Family

ID=69815343

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910968837.8A Active CN110908729B (en) 2019-10-12 2019-10-12 A method of processing command line output information based on regular matching

Country Status (1)

Country Link
CN (1) CN110908729B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114564182A (en) * 2022-01-29 2022-05-31 新华三技术有限公司 Command line checking method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CA2206132A1 (en) * 1994-12-15 1996-06-20 Ufil Unified Data Technologies Ltd. Method and apparatus utilizing bond identifiers executed upon accessing of an endo-dynamic information note (edin)
US7647318B1 (en) * 2003-07-28 2010-01-12 Juniper Networks, Inc. Management interface having fine-grain access control using regular expressions
CN105141444A (en) * 2015-07-24 2015-12-09 中国船舶重工集团公司第七0九研究所 Regular matching-based method and system for generating network management commands
CN106776512A (en) * 2016-12-02 2017-05-31 浪潮通信信息系统有限公司 A kind of general text data processing method
CN107291450A (en) * 2017-05-25 2017-10-24 深圳市彬讯科技有限公司 A kind of quick code automatic generation method for programming friendly

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CA2206132A1 (en) * 1994-12-15 1996-06-20 Ufil Unified Data Technologies Ltd. Method and apparatus utilizing bond identifiers executed upon accessing of an endo-dynamic information note (edin)
US7647318B1 (en) * 2003-07-28 2010-01-12 Juniper Networks, Inc. Management interface having fine-grain access control using regular expressions
CN105141444A (en) * 2015-07-24 2015-12-09 中国船舶重工集团公司第七0九研究所 Regular matching-based method and system for generating network management commands
CN106776512A (en) * 2016-12-02 2017-05-31 浪潮通信信息系统有限公司 A kind of general text data processing method
CN107291450A (en) * 2017-05-25 2017-10-24 深圳市彬讯科技有限公司 A kind of quick code automatic generation method for programming friendly

Also Published As

Publication number Publication date
CN110908729A (en) 2020-03-24

Similar Documents

Publication Publication Date Title
CN104933618B (en) Monitoring method and device for batch job operation data of core bank system
CN103838625B (en) Data interaction method and system
CN109710631A (en) Auxiliary generates method, apparatus, equipment and the computer storage medium of SQL code
CN111291025B (en) Method for supporting multi-physical model conversion by logic model and storage device
CN112199474A (en) Voice customer service method and system
CN115422167A (en) Cross-data source database view visualization construction method and system
CN114691713A (en) Data query method and device
CN113434627A (en) Work order processing method and device and computer readable storage medium
CN110908729B (en) A method of processing command line output information based on regular matching
CN111984670B (en) Method for generating script of annotation information of display view
CN109522005A (en) Cross-platform GRAPHICAL PROGRAMMING method
US20160004968A1 (en) Correlation rule analysis apparatus and correlation rule analysis method
CN113568677A (en) Data object analysis method and device and electronic equipment
CN107273163A (en) A kind of parameter configuration management method and device based on graphic user interface
CN115469849B (en) Service processing system, method, electronic equipment and storage medium
CN112131022A (en) Open API management method, apparatus, system and computer-readable storage medium
CN116643739A (en) Decision engine implementation method, device, equipment and storage medium
CN115018269A (en) Work order data processing method and system
CN106777252A (en) A kind of method and device of uncertain semantic Temporal query middleware
CN112308519A (en) Configuration method of form association rule, form association method and device thereof
CN112612841A (en) Knowledge extraction construction method, device, equipment and storage medium
WO2015033393A1 (en) Design change management assistance method and system therefor
CN116049291B (en) Data storage method, system, device and readable storage medium
CN118643007B (en) Interface document parsing method, device and storage medium
CN110232055B (en) OLAP data analysis migration method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
EE01 Entry into force of recordation of patent licensing contract
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20200324

Assignee: Hangzhou Anheng Information Security Technology Co.,Ltd.

Assignor: Dbappsecurity Co.,Ltd.

Contract record no.: X2024980043364

Denomination of invention: Command line output information processing method based on regular matching

Granted publication date: 20230523

License type: Common License

Record date: 20241231

TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20250506

Address after: No. 10-1-2, Building 1, West Zone, Ningbo New Materials Innovation Center, High tech Zone, Ningbo City, Zhejiang Province 315103

Patentee after: Ningbo Ningshu Security Technology Co.,Ltd.

Country or region after: China

Address before: 310051 15-storey Zhejiang Zhongcai Building, No. 68 Tonghe Road, Binjiang District, Hangzhou City, Zhejiang Province

Patentee before: Dbappsecurity Co.,Ltd.

Country or region before: China