CN110908729A - Command line output information processing method based on regular matching - Google Patents

Command line output information processing method based on regular matching Download PDF

Info

Publication number
CN110908729A
CN110908729A CN201910968837.8A CN201910968837A CN110908729A CN 110908729 A CN110908729 A CN 110908729A CN 201910968837 A CN201910968837 A CN 201910968837A CN 110908729 A CN110908729 A CN 110908729A
Authority
CN
China
Prior art keywords
result
data
command line
command
list
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.)
Granted
Application number
CN201910968837.8A
Other languages
Chinese (zh)
Other versions
CN110908729B (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.)
Hangzhou Dbappsecurity Technology Co Ltd
Original Assignee
Hangzhou Dbappsecurity Technology 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 Hangzhou Dbappsecurity Technology Co Ltd filed Critical Hangzhou Dbappsecurity Technology 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

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 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 processing to the difference of different operating systems and network equipment; the speed of obtaining information by the original command line is optimized, and the space resource required by the running command is reduced. For the service support of a new system (equipment), a user only needs to modify a configuration file without changing too many programs, and the development time and the subsequent maintenance working time are reduced.

Description

Command line output information processing method 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
The operation command is mainly the operation mode of the DOS. No matter the windows system or the Linux system, the running command mode is supported to obtain the running result information of the system. In particular, various network devices, vendor-supplied device interaction interfaces basically include command patterns.
And the SHH, telnet and other tools support remote operation commands, and the operation result of the remote system is displayed on the client.
In general, a user manually inputs a remote command, and when the remote system executes the command, the display end outputs the command operation result.
The command line approach may obtain basic configuration information for the operating system (network device). In a network environment, a remote command line method is a commonly used method for obtaining basic configuration of an operating system.
This method has the following disadvantages:
1. the user needs to manually input each command line and save the original text data. 2. Different systems or devices require different command lines for the same data result, and different raw text data. 3. The user end result data varies with the specific service. 4. Based on the second disadvantage, the automation program faces the problem of how to support the new systems and devices with maximum ergonomics.
Accordingly, there is a need for improvements in the art.
Disclosure of Invention
The invention aims to provide an efficient command line output information processing method based on regular matching.
In order to solve the technical problem, the invention provides a command line output information processing method based on regular matching, which 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; step S2 is executed;
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 command failure waiting time;
the data of the command line regular expression matching table in the command line regular expression matching table comprises the following steps: the method comprises the following steps of (1) identifying a result item name, a unique identification ID of a command line, 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: result item name, description, result expression format and whether the result shows a mark or not;
s2, circularly traversing and executing the specific text commands of the command lines in the command line list file to obtain the text result of command execution; step S3 is executed;
each command line list data and the text result of command execution are used as original result data and stored in an original data set;
each piece of original result data comprises a unique identification ID of a command line, the name of the command line, the 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 result acquisition circulation list;
searching 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, performing step S4; otherwise, acquiring the unique identification ID of the next command line in the circular list for re-detection;
s4, constructing a processing method corresponding to the original data obtained in 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, obtaining analysis processing data, and judging whether the analysis processing data is a final result according to whether a mark is displayed in the result of obtaining the circulation list or not; if the result is the final result, deleting the corresponding result item corresponding to the result item name by the circular list, storing the analysis processing data into the final data, and then executing the step S5;
s5, according to the corresponding intermediate data identification name, judging whether the final result obtained in the step S4 can be used as the result to obtain the original data of other result matching items in the circular list, if the intermediate data identification name is not null, executing the step S6; if the intermediate data identification name is null, executing step S7;
s6, storing the analysis processing data of the final data and the corresponding intermediate data identification name as an intermediate data identification name in the original data; step S7 is executed;
s7, obtaining unprocessed result items in the result obtaining circulation list; step S8 is executed;
s8, judging whether all the data in the circular list are processed or not, and jumping to the step S3 if the data are not processed; if the processing is finished, executing step S9;
s9, judging whether the data is output data or not by judging whether the result of each item of data of the command line result matching table shows a mark or not; if the data is output data, searching the analysis processing data of the final data through the result item name; and reformatting, analyzing and processing the data according to the result expression to obtain a new final result of each item of data.
As an improvement of the command line output information processing method based on the regular matching, the invention comprises the following steps:
in step S2: if the time spent on executing a single command exceeds the failure time of the waiting command, the command is interrupted, and the empty text is taken as the text result of command execution; if the time it takes to execute a single command does not exceed the wait command expiration time, the resulting text is taken as the text result of the command execution.
As a further improvement of the command line output information processing method based on the regular matching, the method comprises the following steps:
in step S4: if the data is missing in the parsing process, an intermediate result data set in the original result data is searched, and if the intermediate result data is not found, step S7 is executed.
As a further improvement of the command line output information processing method based on the regular matching, the method comprises the following steps:
changeable configuration files: the system comprises a command line list, a command line regular expression matching table and a command result matching table.
As a further improvement of the command line output information processing method based on the regular matching, the method comprises the following steps:
the expression 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 mode.
The command line output information processing method based on the regular matching has the technical advantages that:
the invention solves the four problems by combing the command line, regularly analyzing the rule and the relationship between the final data result, stripping the variable service in the command line mode and converting the service into the specific fixed service and the 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 processing to the difference of different operating systems and network equipment; the speed of obtaining information by the original command line is optimized, and the space resource required by the running command is reduced. For the service support of a new system (equipment), a user only needs to modify a configuration file without changing too many programs, and the development time and the subsequent maintenance working time are reduced.
Drawings
The following describes embodiments of the present invention in further detail with reference to the accompanying drawings.
FIG. 1 is a schematic flow chart of a command line output information processing method based on regular matching according to the present invention.
Detailed Description
The invention will be further described with reference to specific examples, but the scope of the invention is not limited thereto.
Embodiment 1, a command line output information processing method based on regular matching, as shown in fig. 1, includes the following steps:
s1, making 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 set manually before step S2 can be performed.
Each piece of data inside each table contains the following attributes:
command line list data in the command line list file: the command line uniquely identifies the ID, the name of the command line, the specific text command of the command line, and the wait for command expiration time.
The command line list data of the command line list file functions only in step S2 as follows:
command line unique identification ID: the identification ID is generated in an incremental mode and corresponds to the unique identification ID of the command line regular expression matching table; after step S2 is executed, the text result is saved as the original result data. A single piece of data of the command line list file corresponds to a plurality of pieces of command line regular expression matching table data.
Name of the command line: the functional type of the command line is defined. After step S2 is executed, the text result is saved as the original result data. The command line names are different and the command execution modes are different. For example, logging in the system requires inputting a user name and a password; acquiring the system configuration function requires input of commands.
Specific text commands for the command line: a textual representation of the command line. After step S2 is executed, the text result is saved as the original result data.
Waiting for command expiration time: the maximum time to wait for the command line to run in step S2 is set. Only acts on the command execution process and is not saved as the original result data.
Matching table data of the command line regular expressions in the command line regular expression matching table: the system comprises a result item name, a unique identification ID of a command line, 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 attributes of the command line regular expression matching table play a role in steps S3 to S8 as follows:
result item name: corresponding to the result item names in the command line result matching table. The result item name set within the command line result match table is a subset of the result item name set of the command line regular expression match table. The result item name is unique.
Command line unique identification ID: corresponding to the command line unique identification ID of the command line list file. By which one piece of command line list data must be found.
Result item default result value: and saving default processing result data. When no results are obtained by parsing the raw data.
The program method identifies the symbol: different regular expressions have different processing methods, and the identification symbol is used for selecting the processing method.
List of program parameters: parameters that are incoming when the data is processed using regular expressions. Different processing methods have different parameters (different types and numbers of parameters), and the original data processing method is determined together with the program method identification symbols and the regular expressions.
The regular expression is as follows: the regular expression used for processing the raw data, together with the list of procedural parameters and procedural method identifiers, determines the raw data processing method.
The identification name of the intermediate data is as follows: when the identification name of the intermediate data is not empty, the processed data can be stored as intermediate data. The intermediate data is distinguished by an intermediate data identification name. The intermediate data identification name is unique.
The data of the command line list file is produced according to the command line list data.
Command line results in the command line results matching table match table data: result item name, description, result expression format, and whether the result shows a mark.
The attributes of the command line result matching table play a role in steps S3 through S9 as follows:
the attributes of the command line result matching table function as follows:
result item name: corresponding to the result item names 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 name of the dependent result item.
The following steps are described: the meaning of the resulting data.
The expression of the result: and the data format used when the result data is output.
Whether the result shows a logo: and a part of results are used as intermediate results of other results, and whether the output is needed or not is judged through the mark.
Whether the result of the command line result matching table shows that the mark is irrelevant to the intermediate data identification name of the command line regular expression matching table or not is judged, the former is used for outputting the final result, and the latter is used for judging whether the processed command result can be used as intermediate data or not.
And S2, circularly traversing and executing each command in the command line list file (saving the specific text command attribute of the command line) to obtain the text result of command execution. If the time spent on executing a single command exceeds the failure time of the waiting command, the command is interrupted, and the empty text is taken as the text result of command execution; if the time it takes to execute a single command does not exceed the wait command expiration time, the resulting text is taken as the text result of the command execution.
And each piece of command line list data and the text result of command execution are used as original result data and are stored in an original data set. The original data set is acted upon in steps S3 to S8.
Each piece of original result data comprises a unique identification ID of a command line, the name of the command line, the specific text of the command line, the text result of the command execution, and no waiting command failure time.
S3, extracts the data in the command line result matching table, and creates a result acquisition loop list (corresponding to the sub-table of the command line result matching table). 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 data of the command line regular expression matching table through the result item name of the single data in the secondary table. After all the command execution results are obtained in the process of S2, S3 reverses the command line result matching table to determine the execution result corresponding to each result.
The original result data in S2 is looked up according to the command line unique identification ID, resulting in the text result of the corresponding command execution in S2. If the corresponding raw result data can be found, performing step S4; otherwise, acquiring the data (the unique identification ID of the command line) of the next item in the circular list for re-detection;
and S4, constructing a processing method corresponding to the original data obtained in S3 according to the program method identification symbol, the program parameter list and the regular expression determined in S3, and analyzing and processing text results executed by the commands in the original result data according to the processing method to obtain analysis and processing data. And judging whether the analysis processing data is the final result or not according to whether the obtained result of the circular list shows the mark or not. If the result is the final result, deleting the corresponding result item corresponding to the result item name by the circular list, storing the analysis processing data into the final data, and then executing the step S5;
in step S3, the method, parameters, and operation results are determined, and in S4, the original data corresponding to the results in S3 are processed by constructing a specific method using a method parameter template.
If there is no data in the parsing process, such as the identifier of the intermediate data required for parsing (the parsing depends on the result of executing other commands, and the result does not turn to the parsing process), the intermediate result data set in the original result data is searched, and if no intermediate result data is found, step S7 is executed.
The final data includes: result item names and parsing process data.
S5, according to the intermediate data identification name, judging whether the final result obtained in the step S4 can be used as the result to obtain the original data of other result matching items in the circular list, if the intermediate data identification name is not null, executing the step S6; if the intermediate data identification name is null, executing step S7;
s6, storing the analysis processing data of the final data and the corresponding intermediate data identification name as an intermediate data identification name in the original data;
the original data set is divided into two parts, one part is the original result data generated in step S1, and the other part is the intermediate result data.
The intermediate result data contains the intermediate data identification name and the parse processing data in step S4. The intermediate result data is used as a parameter by the partial parsing process.
S7, obtaining unprocessed result items in the result obtaining circulation list (the processed result items are removed in step S4);
s8, judging whether all the data in the circular list are processed (the list is empty) or not, and jumping to the step S3 if the data are not processed (the list is not empty); if the processing is finished, executing step S9;
s9, judging whether the data is output data by indicating whether the result of each data item of the command line result matching table shows a mark. If the data is output data, the analysis processing data of the final data is searched through the result item name. And reformatting, analyzing and processing the data according to the result expression to obtain a new final result of each item of data.
Changeable configuration files: the system comprises a command line list, a command line regular expression matching table and a command result matching table.
The internal specific data format of the command line regular expression match table and the resulting command line match 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 an XML file, a text file, a JSON format file, or a database file.
Finally, it is also noted that the above-mentioned lists merely illustrate a few specific embodiments of the invention. It is obvious that the invention is not limited to the above embodiments, but that many variations are possible. All modifications which can be derived or suggested by a person skilled in the art from the disclosure of the present invention are to be considered within the scope of the invention.

Claims (5)

1. The command line output information processing method based on the regular matching is characterized in that: 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; step S2 is executed;
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 command failure waiting time;
the data of the command line regular expression matching table in the command line regular expression matching table comprises the following steps: the method comprises the following steps of (1) identifying a result item name, a unique identification ID of a command line, 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: result item name, description, result expression format and whether the result shows a mark or not;
s2, circularly traversing and executing the specific text commands of the command lines in the command line list file to obtain the text result of command execution; step S3 is executed;
each command line list data and the text result of command execution are used as original result data and stored in an original data set;
each piece of original result data comprises a unique identification ID of a command line, the name of the command line, the 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 result acquisition circulation list;
searching 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, performing step S4; otherwise, acquiring the unique identification ID of the next command line in the circular list for re-detection;
s4, constructing a processing method corresponding to the original data obtained in 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, obtaining analysis processing data, and judging whether the analysis processing data is a final result according to whether a mark is displayed in the result of obtaining the circulation list or not; if the result is the final result, deleting the corresponding result item corresponding to the result item name by the circular list, storing the analysis processing data into the final data, and then executing the step S5;
s5, according to the corresponding intermediate data identification name, judging whether the final result obtained in the step S4 can be used as the result to obtain the original data of other result matching items in the circular list, if the intermediate data identification name is not null, executing the step S6; if the intermediate data identification name is null, executing step S7;
s6, storing the analysis processing data of the final data and the corresponding intermediate data identification name as an intermediate data identification name in the original data; step S7 is executed;
s7, obtaining unprocessed result items in the result obtaining circulation list; step S8 is executed;
s8, judging whether all the data in the circular list are processed or not, and jumping to the step S3 if the data are not processed; if the processing is finished, executing step S9;
s9, judging whether the data is output data or not by judging whether the result of each item of data of the command line result matching table shows a mark or not; if the data is output data, searching the analysis processing data of the final data through the result item name; and reformatting, analyzing and processing the 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, characterized in that:
in step S2: if the time spent on executing a single command exceeds the failure time of the waiting command, the command is interrupted, and the empty text is taken as the text result of command execution; if the time it takes to execute a single command does not exceed the wait command expiration time, the resulting 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, characterized in that:
in step S4: if the data is missing in the parsing process, an intermediate result data set in the original result data is searched, and if the intermediate result data is not found, step S7 is executed.
4. The regular matching based command line output information processing method according to claim 3, wherein:
changeable configuration files: the system comprises a command line list, a command line regular expression matching table and a command result matching table.
5. The regular matching based command line output information processing method according to claim 4, wherein:
the expression 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 mode.
CN201910968837.8A 2019-10-12 2019-10-12 Command line output information processing method 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 Command line output information processing method 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 Command line output information processing method based on regular matching

Publications (2)

Publication Number Publication Date
CN110908729A true CN110908729A (en) 2020-03-24
CN110908729B 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 Command line output information processing method based on regular matching

Country Status (1)

Country Link
CN (1) CN110908729B (en)

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
CN110908729B (en) 2023-05-23

Similar Documents

Publication Publication Date Title
CN106844190B (en) Automatic test script generation method and device
CN109669976B (en) ETL-based data service method and device
CN103870260A (en) Method and system for service interface development
JP4370525B2 (en) Application environment check apparatus and method and program thereof
JP2008134705A (en) Data processing method and data analysis device
JP7031627B2 (en) Analytical equipment, analysis method, and analysis program
CN103544298A (en) Log analysis method and analysis device for component
CN109522005A (en) Cross-platform GRAPHICAL PROGRAMMING method
CN113505054B (en) Network data static test system and test method for unmanned aerial vehicle control station
US20030135496A1 (en) Management program, method and apparatus for business process definition
CN110908729B (en) Command line output information processing method based on regular matching
CN110188432B (en) System architecture verification method, electronic device and computer-readable storage medium
CN112199474A (en) Voice customer service method and system
CN111090665A (en) Data task scheduling method and scheduling system
US11947328B2 (en) Control device, control program, and control system
CN113001538B (en) Command analysis method and system
CN104679740A (en) Data processing system
CN113094088A (en) Database configuration information acquisition method and device, computer equipment and storage medium
JP4351578B2 (en) Production planning support system and computer program
CN111414632A (en) AST self-synthesis-based embedded program data stream security verification method
CN114398366B (en) Heterogeneous data input method and data factory configuration system
JP5253115B2 (en) Program conversion device, program analysis device, program conversion method, program analysis method, and program
CN112131022B (en) Open API management method, device, system and computer readable storage medium
US20100218088A1 (en) Structured document converting device
JP2015156103A (en) Telegram conversion system and telegram conversion method in m2m

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