CN110851125A - Method and system for realizing batch processing of network equipment based on custom script - Google Patents

Method and system for realizing batch processing of network equipment based on custom script Download PDF

Info

Publication number
CN110851125A
CN110851125A CN201910969406.3A CN201910969406A CN110851125A CN 110851125 A CN110851125 A CN 110851125A CN 201910969406 A CN201910969406 A CN 201910969406A CN 110851125 A CN110851125 A CN 110851125A
Authority
CN
China
Prior art keywords
parameter
command
batch processing
custom
script
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.)
Pending
Application number
CN201910969406.3A
Other languages
Chinese (zh)
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.)
Fujian Hongguan Communication Engineering Co Ltd
Original Assignee
Fujian Hongguan Communication Engineering 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 Fujian Hongguan Communication Engineering Co Ltd filed Critical Fujian Hongguan Communication Engineering Co Ltd
Priority to CN201910969406.3A priority Critical patent/CN110851125A/en
Publication of CN110851125A publication Critical patent/CN110851125A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • 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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system

Abstract

The invention provides a method for realizing batch processing of network equipment based on a custom script, which comprises the following steps: step 10, loading a custom script; step 20, analyzing the custom script to obtain an executable command and/or a batch processing command; step 30, directly logging in network equipment to execute the executable command when the executable command is obtained; and when the batch processing command is obtained, generating operation instructions according to the batch processing command, and operating the network equipment one by one. The invention also provides a system for realizing batch processing of the network equipment based on the custom script, which comprises a script loading module, a script analysis module, an executable command execution module and a batch processing command execution module. The method and the system provided by the invention utilize the keyword use case and flexibly call the application program interface to realize the processing and analysis of the character string, can effectively improve the working efficiency of maintaining the network equipment and realize the requirement of diversified batch processing.

Description

Method and system for realizing batch processing of network equipment based on custom script
Technical Field
The invention relates to the field of network equipment, in particular to a method and a system for realizing batch processing of network equipment based on a custom script.
Background
With the development of internet technology, the scale of the network is gradually enlarged, the types and the number of network devices are continuously increased, and the maintenance workload of the whole network is increased dramatically. Therefore, batch processing of network devices is required to reduce maintenance time and improve maintenance efficiency.
When different devices are processed in batch, the traditional mode can only realize batch processing of the same command line, and batch processing according to different device characteristics or according to a preset data plan is difficult to realize. If batch processing planned for different devices or according to preset data is to be realized, a special development programming program is needed to realize the batch processing, so that not only is the cost of the development program increased, but also the function of the programming program is too single, the diversified requirements are difficult to realize, meanwhile, the requirement on maintenance personnel is high, a programming basis is needed, and the programming program is purposefully developed according to the batch processing requirement.
Disclosure of Invention
One of the technical problems to be solved by the present invention is to provide a method for batch processing of network devices based on a custom script, which effectively improves the work efficiency of maintaining the network devices and meets the requirement of diversified batch processing.
One of the technical problems to be solved by the invention is realized as follows:
a method for realizing batch processing of network equipment based on a custom script comprises the following steps:
step 10, loading a custom script;
step 20, analyzing the custom script to obtain an executable command and/or a batch processing command;
step 30, directly logging in network equipment to execute the executable command when the executable command is obtained; and when the batch processing command is obtained, generating an operation instruction according to the batch processing command, and operating the network equipment.
Further, the custom script includes executable commands and/or batch commands, the batch commands include batch command start characters and custom keywords, each executable command and/or batch command end character sets a separator, and the custom script end characters.
Further, the step 20 specifically includes:
analyzing the custom script by command line by taking the separator as a mark;
when the command line does not comprise the batch processing command initial character, judging that the command line is an executable command, and outputting the executable command;
when the command line comprises the batch processing command initial symbol, judging whether the characters after the batch processing command initial symbol belong to the user-defined keyword, if the characters belong to the user-defined keyword, judging that the result is a batch processing command, outputting the batch processing command, if the characters do not belong to the user-defined keyword, judging that the result is a command line error, and ending the analysis;
when the analysis content is the terminator, the analysis is ended.
Further, when the batch processing command is obtained, the generating an operation instruction according to the batch processing command specifically includes:
when the batch processing command is obtained, acquiring the custom keywords included in the batch processing command;
and finding a value function, a condition judgment function, an assignment function and/or an output function corresponding to the custom keyword according to the custom keyword, calling an application program interface corresponding to the function, acquiring parameters from the original configuration of the network equipment and/or an external text through the application program, and generating an operation instruction.
Further, the user-defined keyword case corresponding to the value taking function includes:
& input & parameter a & from (custom text. txt);
& substitet & parameter c (& parameters a, old1, new2, mode);
& mid & parameter b (start1, end2, mode) + instruction 1; and the number of the first and second groups,
& mid & parameter b (start1, end2, mode) - & parameter a;
the user-defined keyword case corresponding to the condition judgment function comprises:
an & if & parameter a < ═ parameter b (instruction 2);
& if & parameter a & find (parameter b) > (instruction 3);
& if & parameter a < ═ parameter b & goto & int 1;
& if & parameter a & find (parameter b) > & 0& goto & int 1; and the number of the first and second groups,
and to & int 1: command line 1;
the user-defined keyword case corresponding to the assignment function comprises:
& catenate & parameter c (parameter a, parameter b); and the number of the first and second groups,
& set & parameter c;
the user-defined keyword use case corresponding to the output function comprises:
output (parameter a, parameter b) & to (new text).
The second technical problem to be solved by the present invention is to provide a system for batch processing of network devices based on a custom script, which effectively improves the work efficiency of maintaining the network devices and meets the requirement of diversified batch processing.
The second technical problem to be solved by the invention is realized as follows:
a system for realizing batch processing of network equipment based on a custom script comprises a script loading module, a script analysis module, an executable command execution module and a batch processing command execution module:
the script loading module is used for loading the custom script;
the script analysis module is used for analyzing the custom script to obtain an executable command and/or a batch processing command;
the command execution module is used for directly logging in the network equipment to execute the executable command when the executable command is obtained; and when the batch processing command is obtained, generating an operation instruction according to the batch processing command, and operating the network equipment.
Further, the custom script includes executable commands and/or batch commands, the batch commands include batch command start characters and custom keywords, each executable command and/or batch command end character sets a separator, and the custom script end characters.
Further, the script parsing module specifically includes:
the command extraction module is used for analyzing the custom script by command line by taking the separator as an end mark of each command line;
the executable command output module is used for judging that the command line does not comprise the batch processing command initial character, and outputting the executable command if the judgment result is the executable command;
the batch processing command output module is used for judging whether the characters after the batch processing command initial symbol belong to the user-defined keyword or not when the command line comprises the batch processing command initial symbol, if the characters belong to the user-defined keyword, the judgment result is a batch processing command, the batch processing command is output, and if the characters do not belong to the user-defined keyword, the judgment result is a command line error, and the analysis is finished;
and the analysis termination module is used for terminating the analysis when the analysis content is the terminator.
Further, when the batch processing command is obtained, the generating an operation instruction according to the batch processing command specifically includes:
when the batch processing command is obtained, acquiring the custom keywords and parameters included in the batch processing command;
and acquiring a value taking function, a condition judging function, a value assigning function and/or an output function corresponding to the custom keyword according to the custom keyword, calling an application program interface corresponding to the function, acquiring parameters from the original configuration of the network equipment and/or an external text through the application program, and generating an operation instruction.
Further, the user-defined keyword case corresponding to the value taking function includes:
& input & parameter a & from (custom text. txt);
& substitet & parameter c (& parameters a, old1, new2, mode);
& mid & parameter b (start1, end2, mode) + instruction 1; and the number of the first and second groups,
& mid & parameter b (start1, end2, mode) - & parameter a;
the user-defined keyword case corresponding to the condition judgment function comprises:
an & if & parameter a < ═ parameter b (instruction 2);
& if & parameter a & find (parameter b) > (instruction 3);
& if & parameter a < ═ parameter b & goto & int 1;
& if & parameter a & find (parameter b) > & 0& goto & int 1; and the number of the first and second groups,
and to & int 1: command line 1;
the user-defined keyword case corresponding to the assignment function comprises:
& catenate & parameter c (parameter a, parameter b); and the number of the first and second groups,
& set & parameter c;
the user-defined keyword use case corresponding to the output function comprises:
output (parameter a, parameter b) & to (new text).
The invention has the following advantages:
analyzing the custom script to obtain an executable command and/or a batch processing command, calling an application program interface by virtue of a predefined keyword grammar case to obtain a designated parameter, and regenerating a new operation instruction to realize diversified automatic batch processing of different network equipment and requirements;
network equipment maintainers can write self-defined scripts by knowing the grammar usage of the user-defined keyword case and referring to the examples without programming basis, thereby effectively improving the work efficiency of maintaining the network equipment and realizing the requirement of diversified batch processing.
Drawings
The invention will be further described with reference to the following examples with reference to the accompanying drawings.
FIG. 1 is a flowchart illustrating a method for batch processing of network devices based on a custom script according to an embodiment of the present disclosure;
FIG. 2 is a schematic structural diagram of a system for batch processing of network devices based on custom scripts according to an embodiment of the present disclosure;
FIG. 3 is a flowchart illustrating a system for batch processing of network devices based on custom scripts according to an embodiment of the present disclosure;
fig. 4 is a flowchart of a keyword use case implementation method for implementing batch processing on network devices based on a custom script according to an embodiment of the present disclosure.
Detailed Description
Referring to fig. 1, an embodiment of the present disclosure provides a method for batch processing of network devices based on a custom script, including:
step 10, loading a custom script;
step 20, analyzing the custom script to obtain an executable command and/or a batch processing command;
step 30, when the executable command is obtained, directly logging in the network device to execute the executable command (for example, logging in the network device by a TELNET, SSH, HTTP and other protocol manner to execute the executable command); and when the batch processing command is obtained, generating an operation instruction according to the batch processing command, and operating the network equipment.
The custom script can be in a TXT text format, the content of the custom script is a command line, and the custom script can be written according to the actual requirement of batch processing of the network equipment and the custom keyword use case so as to realize diversified batch processing of different network equipment and requirements.
In one possible implementation, the custom script includes executable commands and/or batch commands, the batch commands include a batch command start character (e.g., "&") and a custom key, each of the executable commands and/or batch commands end a separator character (e.g., ";") and the custom script end sets an end character (e.g., "& end").
The step 20 specifically includes:
parsing the custom script command line by command line with a separator (such as a separator ";");
when the command line does not comprise the batch command start character (such as "&"), judging that the command line is an executable command, and outputting the executable command;
when the command line comprises the batch processing command start character (such as &), judging whether the character after the batch processing command start character belongs to the self-defined keyword, if so, judging the result to be a batch processing command, outputting the batch processing command, if not, judging the result to be a command line error, and ending the analysis (such as automatically exiting the program and prompting the line language method error);
when the resolution content is an end symbol (for example, "& end") the resolution is ended.
By setting the separators and the terminators, the custom script can be analyzed by command line by using the separators as marks when the custom script is analyzed; when the analysis content is the terminator, the analysis is ended.
In a possible implementation manner, the generating an operation instruction according to the batch processing command when the batch processing command is obtained specifically includes:
when the batch processing command is obtained, acquiring a batch processing command start character and a custom key (such as & input, & substitte, & mid, & if, & to, & catenate, & set or & output) included in the batch processing command;
finding a value function, a condition judgment function, a value function and/or an output function corresponding to the custom keyword according to the custom keyword, calling an Application Program Interface (API) corresponding to the function, acquiring parameters from original configuration and/or external texts (such as txt texts with parameters planned in advance) of network equipment through the application program, and generating an operation instruction; the batch processing requirements of application scenes or processing configured according to different equipment characteristics or application scenes configured or processed by planning different equipment parameters in advance can be met.
Referring to fig. 3, in one possible implementation,
the user-defined keyword case corresponding to the value function comprises:
& input & parameter a & from (custom text. txt); the user-defined text txt is read from the outside by calling the API, and the content is assigned to the parameter a, so that the value can be taken from the planned external text;
& substitet & parameter c (& parameters a, old1, new2, mode); carrying out character string replacement on the parameter a by calling the API, replacing the old1 by the new2, wherein the mode is a replacement mode, the mode value is 0 (default) to replace only the first repeated value, and the mode value is 1 to replace all the repeated values; assigning the result to a parameter c after replacement;
& mid & parameter b (start1, end2, mode) + instruction 1; as shown in fig. 3, after the device is logged in to execute the instruction 1 of the executable command, the echoed content executed by the instruction 1 is returned, the API is called to perform value taking between the start character string and the end character string of the echoed content, and the value is assigned to the parameter b; wherein, the "start 1" is a start symbol, the "end 2" is an end symbol, the "mode" is a value mode, a mode value of 0 (default) indicates that the value result includes the start and end symbols, and a mode value of 1 indicates that the value result does not include the start and end symbols.
& mid & parameter b (start1, end2, mode) - & parameter a; v/calling the API to carry out initial and end dereferencing of the character string on the parameter a and assigning the dereferencing to the parameter b; wherein, the "start 1" is a start symbol, the "end 2" is an end symbol, the "mode" is a value mode, a mode value of 0 (default) indicates that the value result includes the start and end symbols, and a mode value of 1 indicates that the value result does not include the start and end symbols.
The user-defined keyword case corresponding to the condition judgment function comprises:
an & if & parameter a < ═ parameter b (instruction 2); the API is called to compare the sizes of the parameter a and the parameter b, wherein the parameter a and the parameter b are set conditions for comparing the sizes of the parameter a and the parameter b, such as the parameter a and the parameter b, or the parameter a and the parameter b; if the comparison result is True (namely the set condition is met), executing the instruction 2 of the executable command, and if the comparison result is False (namely the set condition is not met), not executing any operation and continuing to analyze the next command line;
& if & parameter a & find (parameter b) > (instruction 3); if the judgment result is True (namely the parameter a contains the parameter b), executing an instruction 3 of the executable command; if the judgment result is False (namely the parameter a does not contain the parameter b), no operation is executed, and the next command line is analyzed continuously;
& if & parameter a < ═ parameter b & goto & int 1; the API is called to compare the parameter a with the parameter b, wherein the parameter a is the parameter b, and the parameter a is the setting condition of the comparison size of the parameter a and the parameter b, such as the parameter a, the parameter b, the parameter a, the parameter b or the parameter a; if the comparison result is True, jumping to the 'int 1' label command line in the script, and if the comparison result is False, not executing any operation and continuously analyzing the next command line;
& if & parameter a & find (parameter b) > & 0& goto & int 1; the calling API judges whether the parameter a contains a parameter b (the symbol is combined together, and is greater than or equal to the parameter b, namely representing the parameter b), if the judgment result is True (namely the parameter a contains the parameter b), the user jumps to a label command line of 'int 1' in the custom script, if the judgment result is False (namely the parameter a does not contain the parameter b), no operation is executed, the next command line is analyzed continuously,
and to & int 1: command line 1; calling API, marking the command line 1 as int1 line, matching with "& goto & int 1", jumping to the command line 1, continuing to analyze and execute the "command line 1", and realizing conditional cycle;
the user-defined keyword case corresponding to the assignment function comprises:
& catenate & parameter c (parameter a, parameter b); v/calling the API to perform string combination on the parameter a and the parameter b, and assigning the newly combined string to the parameter c;
& set & parameter c; I/Call API an instruction with parameter c as an executable command
The user-defined keyword use case corresponding to the output function comprises:
& output (parameter a, parameter b) & to (new text)// calling the API outputs "parameter a, parameter b" to the external text (new text).
The above use cases of custom keywords are only illustrative and not intended to limit the scope of the present invention, and equivalent modifications and variations made by those skilled in the art in light of the spirit of the present invention are intended to be included within the scope of the present invention as defined by the appended claims.
Referring to fig. 4, a keyword use case is implemented by calling an Application Program Interface (API) through a corresponding value function as follows: the method comprises the steps of using a case "& mid & parameter b (start1, end2, num3) + instruction 1 of a custom keyword & mid, and correspondingly calling the method of the API (intercepting index); parameters in the user-defined keyword use case are transmitted to API dynamic parameters, and the general method is as follows:
Figure BDA0002231578730000091
the execution flow of the use case "& mid & parameter b (start1, end2, num3) + instruction 1" of the custom keyword & mid & is as follows: after the login equipment executes the instruction 1 of the executable command, returning the echoed content after the instruction is executed, and carrying out value taking between the initial character symbol and the tail character symbol of the character string on the echoed content by calling the API; and assigned to the "parameter b".
Based on the same idea, the embodiment of the present invention further provides a system corresponding to the above method, as shown in fig. 2.
Fig. 2 is a system for implementing batch processing on network devices based on a custom script corresponding to fig. 1 provided in an embodiment of the present invention, where the system includes: the system comprises a script loading module, a script analysis module, an executable command execution module and a batch processing command execution module:
the script loading module is used for loading the custom script;
the script analysis module is used for analyzing the custom script to obtain an executable command and/or a batch processing command;
the command execution module is used for directly logging in the network equipment to execute the executable command when the executable command is obtained; and when the batch processing command is obtained, generating an operation instruction according to the batch processing command, and operating the network equipment.
In one possible implementation manner, the custom script includes an executable command and/or a batch command, the batch command includes a batch command start character and a custom keyword, a separator character is set at the end of each executable command and/or batch command, and an end character is set at the end of the custom script.
In a possible implementation manner, the script parsing module specifically includes:
the command extraction module is used for analyzing the custom script by command line by taking the separator as an end mark of each command line;
the executable command output module is used for judging that the command line does not comprise the batch processing command initial character, and outputting the executable command if the judgment result is the executable command;
the batch processing command output module is used for judging whether the characters after the batch processing command initial character belong to the user-defined keyword or not when the command line comprises the batch processing command initial character, if the characters belong to the user-defined keyword, the judgment result is a batch processing command, the batch processing command is output, and if the characters do not belong to the user-defined keyword, the judgment result is a command line error, and the analysis is finished;
and the analysis termination module is used for terminating the analysis when the analysis content is the terminator.
In a possible implementation manner, the generating an operation instruction according to the batch processing command when the batch processing command is obtained specifically includes:
when the batch processing command is obtained, acquiring the custom keywords and parameters included in the batch processing command;
and acquiring a value taking function, a condition judging function, a value assigning function and/or an output function corresponding to the custom keyword according to the custom keyword, calling an application program interface corresponding to the function, acquiring parameters from the original configuration of the network equipment and/or an external text through the application program, and generating an operation instruction.
In a possible implementation manner, the user-defined keyword use case corresponding to the value taking function includes:
the user-defined keyword case corresponding to the value function comprises:
& input & parameter a & from (custom text. txt);
& substitet & parameter c (& parameters a, old1, new2, mode);
& mid & parameter b (start1, end2, mode) + instruction 1; and the number of the first and second groups,
& mid & parameter b (start1, end2, mode) - & parameter a;
the user-defined keyword case corresponding to the condition judgment function comprises:
an & if & parameter a < ═ parameter b (instruction 2);
& if & parameter a & find (parameter b) > (instruction 3);
& if & parameter a < ═ parameter b & goto & int 1;
& if & parameter a & find (parameter b) > & 0& goto & int 1; and the number of the first and second groups,
and to & int 1: command line 1;
the user-defined keyword case corresponding to the assignment function comprises:
& catenate & parameter c (parameter a, parameter b); and the number of the first and second groups,
& set & parameter c;
the user-defined keyword use case corresponding to the output function comprises:
output (parameter a, parameter b) & to (new text).
The present specification provides an embodiment of a custom script, which implements batch modification of network address segments for managing IP addresses under the same management VLAN of different network devices, where the script is specifically as follows:
system-view; v/Note command line 1
&mid&Old_Ip("interface Vlan-interface100","#",1)+"display
current-configuration "; v/Note command line 2
& if & Old _ Ip & find ("10.1.1") ═ 0& goto & "1"; v/Note command line 3
& substitete & new _ Ip (& Old _ Ip, "10.1.1", "10.2.2", 0); v/Note command line 4
interface Vlan-interface 100; v/Note command line 5
undoo ip address; v/Note command line 6
& set & new _ Ip; v/Note command line 7
end; v/Note command line 8
save; v/Note command line 9
& to &1: & end; v/Note command line 10
The results after execution are as follows:
Figure BDA0002231578730000111
Figure BDA0002231578730000121
by the self-defined script example, the network address segments meeting the requirements can be modified in batch for all the equipment without making different scripts for each equipment.
Custom script format example parsing:
1. command line 1: system-view;
and (3) analysis: the case syntax of the keyword is not contained, the case syntax is judged to be an executable command, and a tail separator is removed; ", perform a" system-view "on the login device.
2. Command line 2:, & mid & Old _ Ip ("interface Vlan-interface100", "#",1) + "displaycurrent-configuration";
and (3) analysis: the command line comprises a & mid & keyword case, an API is called, a login device executes a display-configuration, the content of the playback of the execution command is acquired and stored in a memory, and after the last value of the character string is taken, the parameter is assigned to the parameter, & Old _ Ip ";
Figure BDA0002231578730000122
3. command line 3: & if & Old _ Ip & find ("10.1.1") ═ 0& goto & "1";
and (3) analysis: the command line contains & if & goto keyword use cases, calls API, judges that & Old _ Ip does not contain '10.1.1', and executes jump to the command line 'label line 1', namely jump to 'end'; "the system automatically quits to finish; if "10.1.1" is included, parsing continues with the next command line. In this example & old _ Ip contains "10.1.1" and the system continues to parse the next command line.
4. Command line 4: & substitete & new _ Ip (& old _ Ip, "10.1.1", "10.2.2", 0);
and (3) analysis: the command comprises a sub and keyword use case, an API is called, and the value of the character string of the old _ Ip is replaced: the value result of & new _ Ip is 'Ip address 10.2.2.38255.255.255.240';
5. command line 7: & set & new _ Ip;
and (3) analysis: the command comprises a & set & keyword use case, an API is called, the & new _ Ip is used as a new command of the executable command, and the login device executes 'Ip address 10.1.1.38255.255.255.240';
6. command line 10: & to &1: & end;
and (3) analysis: the command contains & to &1 key use case, calls API, marks the command line as "Mark line 1", and continues parsing ": "later sentence" & end; ", judging that includes" & end; "end marker, end of system parsing, exit.
The invention can realize diversified batch processing methods for different network devices and requirements through the custom script; by means of a pre-defined keyword grammar case, original configuration parameters of each network device or the content of an external text are subjected to character string access analysis, new operation instructions are generated again, and then automatic batch processing is realized on the network devices; network equipment maintainers or other users can write self-defined scripts by using the system without programming basis and only by referring to examples and knowing the grammar usage of the keyword use case, thereby effectively improving the working efficiency of maintaining network equipment and realizing the requirement of diversified batch processing.
Although specific embodiments of the invention have been described above, it will be understood by those skilled in the art that the specific embodiments described are illustrative only and are not limiting upon the scope of the invention, and that equivalent modifications and variations can be made by those skilled in the art without departing from the spirit of the invention, which is to be limited only by the appended claims.

Claims (10)

1. A method for realizing batch processing of network equipment based on a custom script is characterized by comprising the following steps:
step 10, loading a custom script;
step 20, analyzing the custom script to obtain an executable command and/or a batch processing command;
step 30, directly logging in network equipment to execute the executable command when the executable command is obtained; and when the batch processing command is obtained, generating an operation instruction according to the batch processing command, and operating the network equipment.
2. The method for batch processing of network devices based on custom scripts according to claim 1, wherein: the custom script comprises executable commands and/or batch commands, the batch commands comprise batch command start characters and custom keywords, separator characters are arranged at the tail end of each executable command and/or batch command, and the end characters are arranged at the tail end of the custom script.
3. The method for batch processing of network devices based on custom scripts according to claim 2, wherein the step 20 specifically includes:
analyzing the custom script by command line by taking the separator as a mark;
when the command line does not comprise the batch processing command initial character, judging that the command line is an executable command, and outputting the executable command;
when the command line comprises the batch processing command initial symbol, judging whether the characters after the batch processing command initial symbol belong to the user-defined keyword, if the characters belong to the user-defined keyword, judging that the result is a batch processing command, outputting the batch processing command, if the characters do not belong to the user-defined keyword, judging that the result is a command line error, and ending the analysis;
when the analysis content is the terminator, the analysis is ended.
4. The method according to claim 2, wherein the generating the operation instruction according to the batch processing command when the batch processing command is obtained specifically includes:
when the batch processing command is obtained, acquiring the custom keywords included in the batch processing command;
and finding a value function, a condition judgment function, an assignment function and/or an output function corresponding to the custom keyword according to the custom keyword, calling an application program interface corresponding to the function, acquiring parameters from the original configuration of the network equipment and/or an external text through the application program, and generating an operation instruction.
5. The method for batch processing of network devices based on custom scripts according to claim 4, wherein:
the user-defined keyword case corresponding to the value function comprises:
& input & parameter a & from (custom text. txt);
& substitet & parameter c (& parameters a, old1, new2, mode);
& mid & parameter b (start1, end2, mode) + instruction 1; and the number of the first and second groups,
& mid & parameter b (start1, end2, mode) - & parameter a;
the user-defined keyword case corresponding to the condition judgment function comprises:
an & if & parameter a < ═ parameter b (instruction 2);
& if & parameter a & find (parameter b) > (instruction 3);
& if & parameter a < ═ parameter b & goto & int 1;
& if & parameter a & find (parameter b) > & 0& goto & int 1; and the number of the first and second groups,
and to & int 1: command line 1;
the user-defined keyword case corresponding to the assignment function comprises:
& catenate & parameter c (parameter a, parameter b); and the number of the first and second groups,
& set & parameter c;
the user-defined keyword use case corresponding to the output function comprises:
output (parameter a, parameter b) & to (new text).
6. A system for realizing batch processing of network equipment based on custom scripts is characterized in that: the system comprises a script loading module, a script analysis module, an executable command execution module and a batch processing command execution module:
the script loading module is used for loading the custom script;
the script analysis module is used for analyzing the custom script to obtain an executable command and/or a batch processing command;
the command execution module is used for directly logging in the network equipment to execute the executable command when the executable command is obtained; and when the batch processing command is obtained, generating an operation instruction according to the batch processing command, and operating the network equipment.
7. The system of claim 6, wherein the system is configured to batch process network devices based on custom scripts, and further configured to: the custom script comprises executable commands and/or batch commands, the batch commands comprise batch command start characters and custom keywords, separator characters are arranged at the tail end of each executable command and/or batch command, and the end characters are arranged at the tail end of the custom script.
8. The system for batch processing of network devices based on custom scripts according to claim 7, wherein the script parsing module specifically comprises:
the command extraction module is used for analyzing the custom script by command line by taking the separator as an end mark of each command line;
the executable command output module is used for judging that the command line does not comprise the batch processing command initial character, and outputting the executable command if the judgment result is the executable command;
the batch processing command output module is used for judging whether the characters after the batch processing command initial symbol belong to the user-defined keyword or not when the command line comprises the batch processing command initial symbol, if the characters belong to the user-defined keyword, the judgment result is a batch processing command, the batch processing command is output, and if the characters do not belong to the user-defined keyword, the judgment result is a command line error, and the analysis is finished;
and the analysis termination module is used for terminating the analysis when the analysis content is the terminator.
9. The system according to claim 7, wherein the generating the operation instruction according to the batch processing command when the batch processing command is obtained specifically includes:
when the batch processing command is obtained, acquiring the custom keywords and parameters included in the batch processing command;
and acquiring a value taking function, a condition judging function, a value assigning function and/or an output function corresponding to the custom keyword according to the custom keyword, calling an application program interface corresponding to the function, acquiring parameters from the original configuration of the network equipment and/or an external text through the application program, and generating an operation instruction.
10. The system according to claim 9, wherein the system is configured to batch process network devices based on custom scripts, and comprises:
the user-defined keyword case corresponding to the value function comprises:
& input & parameter a & from (custom text. txt);
& substitet & parameter c (& parameters a, old1, new2, mode);
& mid & parameter b (start1, end2, mode) + instruction 1; and the number of the first and second groups,
& mid & parameter b (start1, end2, mode) - & parameter a;
the user-defined keyword case corresponding to the condition judgment function comprises:
an & if & parameter a < ═ parameter b (instruction 2);
& if & parameter a & find (parameter b) > (instruction 3);
& if & parameter a < ═ parameter b & goto & int 1;
& if & parameter a & find (parameter b) > & 0& goto & int 1; and the number of the first and second groups,
and to & int 1: command line 1;
the user-defined keyword case corresponding to the assignment function comprises:
& catenate & parameter c (parameter a, parameter b); and the number of the first and second groups,
& set & parameter c;
the user-defined keyword use case corresponding to the output function comprises:
output (parameter a, parameter b) & to (new text).
CN201910969406.3A 2019-10-12 2019-10-12 Method and system for realizing batch processing of network equipment based on custom script Pending CN110851125A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910969406.3A CN110851125A (en) 2019-10-12 2019-10-12 Method and system for realizing batch processing of network equipment based on custom script

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910969406.3A CN110851125A (en) 2019-10-12 2019-10-12 Method and system for realizing batch processing of network equipment based on custom script

Publications (1)

Publication Number Publication Date
CN110851125A true CN110851125A (en) 2020-02-28

Family

ID=69597357

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910969406.3A Pending CN110851125A (en) 2019-10-12 2019-10-12 Method and system for realizing batch processing of network equipment based on custom script

Country Status (1)

Country Link
CN (1) CN110851125A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104376296A (en) * 2014-12-03 2015-02-25 福建鑫诺通讯技术有限公司 Barcode reader setting method and barcode reader setting device
WO2015196805A1 (en) * 2014-06-23 2015-12-30 中兴通讯股份有限公司 Batch command execution method and apparatus
CN107222336A (en) * 2017-05-27 2017-09-29 国网山东省电力公司临沂供电公司 A kind of graphical network management system and method
CN109981342A (en) * 2019-02-15 2019-07-05 广州市高科通信技术股份有限公司 A kind of method and system of batch processing network device operation order

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2015196805A1 (en) * 2014-06-23 2015-12-30 中兴通讯股份有限公司 Batch command execution method and apparatus
CN104376296A (en) * 2014-12-03 2015-02-25 福建鑫诺通讯技术有限公司 Barcode reader setting method and barcode reader setting device
CN107222336A (en) * 2017-05-27 2017-09-29 国网山东省电力公司临沂供电公司 A kind of graphical network management system and method
CN109981342A (en) * 2019-02-15 2019-07-05 广州市高科通信技术股份有限公司 A kind of method and system of batch processing network device operation order

Similar Documents

Publication Publication Date Title
US9223570B2 (en) Migration assistance using compiler metadata
CN110210212A (en) A kind of data processing method, device and relevant device
CN111124479B (en) Method and system for analyzing configuration file and electronic equipment
CN111736840A (en) Compiling method and running method of applet, storage medium and electronic equipment
CN109460250B (en) Application program generation method and device
CN103294598A (en) Method and device for source code inspection
CN109492181A (en) Method for page jump, device, computer equipment and storage medium
CN113806037A (en) Service calling method and device, storage medium and electronic equipment
CN109542444B (en) JAVA application monitoring method, device, server and storage medium
CN112398809A (en) Protocol rule conversion method, device, computer equipment and storage medium
JP2021002326A (en) Refinement of repair patterns for static analysis violations in software programs
CN114760369A (en) Protocol metadata extraction method, device, equipment and storage medium
CN106789205A (en) Group of planes order operation method and system
CN114238151A (en) Software testing method and device, electronic equipment and storage medium
CN108234339B (en) Message forwarding method of programmable data plane
CN113535586A (en) Test environment switching method, device, equipment and readable storage medium
CN108153745B (en) Application data calling method and application development system
CN110851125A (en) Method and system for realizing batch processing of network equipment based on custom script
US10360139B2 (en) Identifying transport-level encoded payloads
CN113138913A (en) Java code injection detection method, device, equipment and storage medium
CN109960590A (en) A method of optimization embedded system diagnostic printing
US20190258462A1 (en) Batch script decomposer
CN115048277A (en) Log analysis method, device, equipment and storage medium for data audit
CN107608887A (en) A kind of method for creating virtual opetrating system test server
CN108304358A (en) Based on the land data analysis method of inertial navigation product SDCard storage devices

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20200228