CN111124734A - Method and device for processing exception in script running process - Google Patents
Method and device for processing exception in script running process Download PDFInfo
- Publication number
- CN111124734A CN111124734A CN201911353064.9A CN201911353064A CN111124734A CN 111124734 A CN111124734 A CN 111124734A CN 201911353064 A CN201911353064 A CN 201911353064A CN 111124734 A CN111124734 A CN 111124734A
- Authority
- CN
- China
- Prior art keywords
- script
- exception
- type
- function
- configuration
- 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
Links
- 238000013515 script Methods 0.000 title claims abstract description 251
- 238000000034 method Methods 0.000 title claims abstract description 105
- 230000008569 process Effects 0.000 title claims abstract description 85
- 230000002159 abnormal effect Effects 0.000 claims description 41
- 238000012360 testing method Methods 0.000 claims description 30
- 238000011084 recovery Methods 0.000 claims description 18
- 230000005856 abnormality Effects 0.000 claims description 14
- 238000010586 diagram Methods 0.000 description 4
- 230000008859 change Effects 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 101100439974 Streptococcus pneumoniae serotype 4 (strain ATCC BAA-334 / TIGR4) clpE gene Proteins 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/0703—Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
- G06F11/0793—Remedial or corrective actions
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention discloses a method and a device for processing exception in the running process of a script. Therefore, as one script function is adopted to process all the exceptions occurring in the script running process, and the script function can be called by all the scripts, the exceptions in the script running process can be processed uniformly, the exception processing is easy to operate, and the named lines of the scripts are reduced.
Description
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for processing an exception in a script running process.
Background
In the field of computer technology, a Script (Script) is an extension of a batch file, and is a program stored in plain text, and generally, a Script is a definite series of combinations of operations for controlling a computer to perform operations, in which certain logical branches and the like can be implemented. Many abnormal situations can occur in the running process of the script, and at the moment, the abnormal situations need to be processed, so that the script can run normally.
At present, exception handling in the running process of a script is respectively performed in each script, that is, a command line for exception handling is set in each script, and when an exception occurs in a running script, the set command line corresponding to the exception handling is called and then executed. However, the exception handling method in the script running process has the following disadvantages: exception handling causes the command lines of the scripts to be increased, and situations are likely to occur in which some script exceptions are missed. Further, when some exception processing needs to be added, modified or deleted, a command line corresponding to the processing to be added, modified or deleted in each script needs to be modified, which not only increases the unnecessary workload, but also increases the probability of a modification error and the time for verifying the script.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method for handling an exception in a script running process, where the method can uniformly handle exceptions in all script running processes, change exception handling is easy to operate, and named lines of a script are reduced.
The embodiment of the invention also provides a device for processing the exception in the running process of the script, which can uniformly process the exception in the running process of all the scripts, is easy to change the exception processing and reduces the named lines of the scripts.
The embodiment of the invention is realized as follows:
a method for processing exception in script operation process includes:
setting a script function, wherein the script function comprises operation commands for correspondingly processing different exception types;
and when the abnormality is captured in the running process of the script, calling the script function, executing an operation command corresponding to the abnormal type, and performing abnormality processing.
The exception types include:
abnormal condition of script basic configuration failure, wherein the abnormal type is set as FLAGA;
after the script is executed, carrying out failure exception during configuration recovery, and setting the type as FLAGD;
when the script is subjected to an abnormal condition that the script cannot continue to run due to a sudden problem in the execution process, setting the abnormal type as FLAGE;
and in the script test process, the type of the exception of the failure of uploading the equipment configuration file is set as FLAGF.
When the exception type is an exception which fails to be configured on the basis of the script, the exception handling includes:
calling a script function to perform exception handling by adopting a corresponding operation command, and reporting success when basic configuration is successful; when the script basic configuration fails, reporting the failure, and setting failure information in a test report; controlling the script to stop running and downloading initialization files of all tested devices; renaming the test report and the log file to enable the file name to contain the operation exception type, and informing the main process that the script is abnormal in operation.
When the exception type is an exception which fails in configuration recovery after the script execution is finished, the exception handling includes:
calling a script function to execute a corresponding operation command to perform exception handling, reporting to be successful if the recovery configuration is successful, reporting to be failed if the recovery configuration is failed, and setting failure information in a test report; and controlling the script to stop running, downloading the initialization files of all the tested devices, and informing the main process that the script runs abnormally.
When the exception type is an exception that the script cannot continue to run when encountering a burst problem, the exception handling includes:
a script function is called to analyze the type of the abnormality, the detailed reason of the abnormality error is translated, and the result is sent to the script; the script function controls the script to stop running and downloads initialization files of all tested devices; renaming the test report and the log file to enable the file name to contain the operation exception type, and informing the main process that the script is abnormal in operation.
When the exception type is an exception that the uploading of the device configuration file fails, the exception handling includes:
after the script is executed, calling a script function to check whether all the configuration files are uploaded successfully or not, carrying out exception processing on the script function by adopting a corresponding operation command, and reporting successfully if all the configuration files are uploaded successfully; and if the configuration file has the condition of uploading failure, setting all configuration file names which fail to be reported in the report failure report.
And the script function correspondingly processes the operation commands of different exception types and is added, modified or deleted aiming at the exception types.
An exception handling device for a script in a running process comprises: a script function setting unit and an exception handling unit, wherein,
the script function setting unit is used for setting script functions, wherein the script functions comprise operation commands for correspondingly processing different exception types;
and the exception handling unit is used for calling the script function in the script function setting unit when the exception is captured in the running process of the script, executing the operation command corresponding to the exception type and carrying out exception handling.
The exception types include:
abnormal condition of script basic configuration failure, wherein the abnormal type is set as FLAGA;
after the script is executed, carrying out failure exception during configuration recovery, and setting the type as FLAGD;
when the script is subjected to an abnormal condition that the script cannot continue to run due to a sudden problem in the execution process, setting the abnormal type as FLAGE;
and in the script test process, the type of the exception of the failure of uploading the equipment configuration file is set as FLAGF.
And the script function correspondingly processes the operation commands of different exception types and is added, modified or deleted aiming at the exception types.
As can be seen from the above, the embodiment of the present invention sets the script function, where the script function includes command lines for correspondingly processing different exception types, and when an exception is captured in the running process of the script, the script function is called to execute the command line corresponding to the exception type to perform exception processing. Therefore, as one script function is adopted to process all the exceptions occurring in the script running process, and the script function can be called by all the scripts, the exceptions in the script running process can be processed uniformly, the exception processing is easy to operate, and the named lines of the scripts are reduced.
Drawings
Fig. 1 is a flowchart of an exception handling method in a script running process according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a process for calling a script function in a script running process according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of an exception handling apparatus in a script running process according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is further described in detail below with reference to the accompanying drawings and examples.
The main disadvantage of exception handling in the running process of the script in the background art is that the exception handling in the running process of the script is performed in each script, so that each script needs to be modified when the exception handling is updated, and each script may have a repeated command line for processing the same exception. In order to solve the problem, in the embodiment of the present invention, a script function is set, where the script function includes command lines for correspondingly processing different exception types, and when an exception is captured in a script running process, the script function is called to execute the command line corresponding to the exception type to perform exception processing.
Therefore, as one script function is adopted to process all the exceptions occurring in the script running process, and the script function can be called by all the scripts, the exceptions in the script running process can be processed uniformly, the exception processing is easy to operate, and the named lines of the scripts are reduced.
The invention actually sets the script function, wherein the script function has the operation flow information for processing the abnormal condition of the script, all scripts share one set of abnormal processing mechanism, the reliability of the script is increased, and the working efficiency is improved.
Fig. 1 is a flowchart of an exception handling method in a script running process according to an embodiment of the present invention, which includes the following specific steps:
and 102, when the abnormality is captured in the script running process, calling the script function, executing an operation command corresponding to the abnormal type, and performing abnormality processing.
In the method, the exception mainly comprises 4 types, and the script function sets an operation command for the 4 types of exception handling. The types of exceptions include: abnormal condition of script basic configuration failure, wherein the abnormal type is set as FLAGA; after the script is executed, carrying out failure exception during configuration recovery, and setting the type as FLAGD; when the script is subjected to an abnormal condition that the script cannot continue to run due to a sudden problem in the execution process, setting the abnormal type as FLAGE; and in the script test process, the type of the exception of the failure of uploading the equipment configuration file is set as FLAGF.
When exception handling is carried out and is failed in script basic configuration, the whole process is as follows:
and (5) starting script operation, and firstly carrying out test basic configuration. After the basic configuration of the script is completed, the script function is called, because the subsequent test result of the script is affected by the basic configuration failure of the script, exception handling is performed on the basic configuration failure of the script. When the script function adopts the corresponding operation command to perform exception handling, reporting success when the basic configuration is successful; when the script basic configuration fails, reporting the failure, and setting failure information in a test report; controlling the script to stop running and downloading initialization files of all tested devices; renaming the test report and the log (log) file to enable the file name to contain the operation exception type, and informing the main process that the script is abnormal in operation.
When exception processing is failure exception when configuration recovery is carried out after script execution is finished, the whole process is as follows:
after the script operation is finished, all the device configurations are deleted, if the configuration clearing is failed, the execution of the next script is influenced, and therefore when the configuration recovery failure is captured in the script operation process, a script function is called to perform exception handling. When the script function executes the corresponding operation command to perform exception handling, if the recovery configuration is successful, reporting success, if the recovery configuration is failed, reporting failure, and setting failure information in a test report; and controlling the script to stop running, downloading the initialization files of all the tested devices, and informing the main process that the script runs abnormally.
When exception handling is an exception that the script cannot continue to run due to a burst problem in the script execution process, the whole process is as follows:
during the running process of the script, abnormalities such as internet telnet service standard protocol (telnet) interruption, variable errors, tester connection errors or test configuration errors may occur, and once these problems occur, the script cannot continue to run and needs to be reported to the main process and correspondingly processed. Therefore, when the script has the burst exception, the following process is performed.
The script calls a script function, the script function analyzes the type of the abnormality, translates the detailed reason of the abnormality error and sends the result to the script, so that the script executor can conveniently perform error positioning; controlling the script to stop running and downloading initialization files of all tested devices; renaming the test report and the log file to enable the file name to contain the operation exception type, and informing the main process that the script is abnormal in operation.
When the exception handling is an exception that the uploading of the device configuration file fails in the script test process, the whole process is as follows:
after each stage (case) of script operation is completed, all configuration files of the tested equipment and configuration files of the tester are uploaded, so that subsequent positioning is facilitated. After the script is executed, calling a script function to check whether all the configuration files are uploaded successfully or not, carrying out exception processing on the script function by adopting a corresponding operation command, and reporting successfully if all the configuration files are uploaded successfully; and if the configuration file has the condition of uploading failure, setting all configuration file names which fail to be reported in the report failure report.
In the method, the operation commands of different exception types are correspondingly processed in the script function, and are added, modified or deleted aiming at the exception types.
Fig. 2 is a schematic process diagram of a script function called by a script running process according to an embodiment of the present invention, which specifically includes the following steps:
step 205, in the process of executing the command line of the case2 by the script, capturing whether an exception with the type of flag exists, if not, executing step 206; if so, go to step 212;
step 208, the script execution is finished;
and step 214, calling the script function by the script to perform failed exception handling during configuration recovery.
The specific implementation of the script function is as follows.
The script function functions: printed exception output in test report
Inputting parameters: file id: file descriptor for test report
fd _ log: testing the file descriptor of a log
flagErr: test results
flagType: type of error of answer
startSeconds: time, unit s, when script starts to run
printWord 1: character string \ printed with error test result
(if the flag type is FLAGF, the variable is the list of the names of the configuration files which have failed to upload)
printWord 2: character string with correctly printed test result
filiename: name of test report (not containing _ report _ log field)
lswawn _ id: list of device spawn _ id
l MatchType: matching command line node string lists
lDutType: device type list
lIp: device telnet ip list
lFileName: device initialization file list
Outputting parameters: is free of
# return value: 0/1.
The script function specifically uses commands as follows:
function # function: common error analysis of script,
# input parameters: err: error information returned by tcl
Output parameter # output: printErr
# return value: is free of
Take a specific example to explain
The example is an exception handling process of telnet connection interruption of a device in the running process of a script, and the specific process comprises the following steps:
the method comprises the following steps that firstly, a script captures exception information, then calls a set script function GWPUpic _ printAbsormal, and transmits an exception type 'FLAGE' and exception information 'spawn id exp4 not open' as entries to an ontology of the script function;
secondly, in the process of script function processing, finding a corresponding operation command according to an abnormal type 'FLAGE', calling a function GWPublic _ errNalyer therein, comparing abnormal information in the function, matching a matching item { spawn id exp/d + not open }, and then classifying and translating the abnormal;
and thirdly, renaming the script test report and the name of the log file to indicate that the script is not finished and informing the main process of the equipment of abnormal exit information.
Fig. 3 is a schematic structural diagram of an exception handling device in a script running process according to an embodiment of the present invention, including: a script function setting unit and an exception handling unit, wherein,
the script function setting unit is used for setting script functions, wherein the script functions comprise operation commands for correspondingly processing different exception types;
and the exception handling unit is used for calling the script function in the script function setting unit when the exception is captured in the running process of the script, executing the operation command corresponding to the exception type and carrying out exception handling.
In the apparatus, the abnormality types include:
abnormal condition of script basic configuration failure, wherein the abnormal type is set as FLAGA;
after the script is executed, carrying out failure exception during configuration recovery, and setting the type as FLAGD;
when the script is subjected to an abnormal condition that the script cannot continue to run due to a sudden problem in the execution process, setting the abnormal type as FLAGE;
and in the script test process, the type of the exception of the failure of uploading the equipment configuration file is set as FLAGF.
In the device, the operation commands of different exception types are correspondingly processed in the script function, and are added, modified or deleted aiming at the exception types.
The script function provided by the embodiment of the invention has good expansibility and portability, can be added with various operation commands required by the exception handling process at will, does not need to modify the script when adding the exception handling, only needs to be expanded into the operation commands of exception types and exception handling in the script function, and can be added at will for handling sudden exceptions. As the script function provided by the embodiment of the invention does not depend on specific equipment, the script function can be well transplanted to other platforms and other modules,
the above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.
Claims (10)
1. A method for processing exception in script operation process is characterized by comprising the following steps:
setting a script function, wherein the script function comprises operation commands for correspondingly processing different exception types;
and when the abnormality is captured in the running process of the script, calling the script function, executing an operation command corresponding to the abnormal type, and performing abnormality processing.
2. The method of claim 1, wherein the exception type comprises:
abnormal condition of script basic configuration failure, wherein the abnormal type is set as FLAGA;
after the script is executed, carrying out failure exception during configuration recovery, and setting the type as FLAGD;
when the script is subjected to an abnormal condition that the script cannot continue to run due to a sudden problem in the execution process, setting the abnormal type as FLAGE;
and in the script test process, the type of the exception of the failure of uploading the equipment configuration file is set as FLAGF.
3. The method of claim 2, wherein when the exception type is a script based configuration failed exception, the performing exception handling comprises:
calling a script function to perform exception handling by adopting a corresponding operation command, and reporting success when basic configuration is successful; when the script basic configuration fails, reporting the failure, and setting failure information in a test report; controlling the script to stop running and downloading initialization files of all tested devices; renaming the test report and the log file to enable the file name to contain the operation exception type, and informing the main process that the script is abnormal in operation.
4. The method of claim 2, wherein when the exception type is an exception that fails when performing configuration recovery after completion of script execution, said performing exception handling comprises:
calling a script function to execute a corresponding operation command to perform exception handling, reporting to be successful if the recovery configuration is successful, reporting to be failed if the recovery configuration is failed, and setting failure information in a test report; and controlling the script to stop running, downloading the initialization files of all the tested devices, and informing the main process that the script runs abnormally.
5. The method of claim 2, wherein when the exception type is an exception in which the script encounters a burst problem and cannot continue to run, the performing exception handling comprises:
a script function is called to analyze the type of the abnormality, the detailed reason of the abnormality error is translated, and the result is sent to the script; the script function controls the script to stop running and downloads initialization files of all tested devices; renaming the test report and the log file to enable the file name to contain the operation exception type, and informing the main process that the script is abnormal in operation.
6. The method of claim 2, wherein when the exception type is an exception that uploading the device profile fails, the performing exception handling comprises:
after the script is executed, calling a script function to check whether all the configuration files are uploaded successfully or not, carrying out exception processing on the script function by adopting a corresponding operation command, and reporting successfully if all the configuration files are uploaded successfully; and if the configuration file has the condition of uploading failure, setting all configuration file names which fail to be reported in the report failure report.
7. The method of claim 1, wherein the corresponding operation commands in the script function for handling different exception types are added, modified or deleted for exception types.
8. An exception handling apparatus for a script in operation, comprising: a script function setting unit and an exception handling unit, wherein,
the script function setting unit is used for setting script functions, wherein the script functions comprise operation commands for correspondingly processing different exception types;
and the exception handling unit is used for calling the script function in the script function setting unit when the exception is captured in the running process of the script, executing the operation command corresponding to the exception type and carrying out exception handling.
9. The apparatus of claim 7, wherein the exception type comprises:
abnormal condition of script basic configuration failure, wherein the abnormal type is set as FLAGA;
after the script is executed, carrying out failure exception during configuration recovery, and setting the type as FLAGD;
when the script is subjected to an abnormal condition that the script cannot continue to run due to a sudden problem in the execution process, setting the abnormal type as FLAGE;
and in the script test process, the type of the exception of the failure of uploading the equipment configuration file is set as FLAGF.
10. The apparatus of claim 8, wherein the script function handles different exception type operation commands, added, modified or deleted for exception types.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911353064.9A CN111124734A (en) | 2019-12-25 | 2019-12-25 | Method and device for processing exception in script running process |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911353064.9A CN111124734A (en) | 2019-12-25 | 2019-12-25 | Method and device for processing exception in script running process |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111124734A true CN111124734A (en) | 2020-05-08 |
Family
ID=70502583
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201911353064.9A Pending CN111124734A (en) | 2019-12-25 | 2019-12-25 | Method and device for processing exception in script running process |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111124734A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113886122A (en) * | 2021-09-30 | 2022-01-04 | 济南浪潮数据技术有限公司 | System operation exception handling method, device, equipment and storage medium |
US11343305B2 (en) | 2020-09-01 | 2022-05-24 | UiPath Inc. | Systems and methods of automating a file download activity |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102981943A (en) * | 2012-10-29 | 2013-03-20 | 新浪技术(中国)有限公司 | Method and system for monitoring application logs |
US20140149978A1 (en) * | 2012-11-26 | 2014-05-29 | Oracle International Corporation | Dynamic communication between script and execution layers |
CN109325865A (en) * | 2018-08-13 | 2019-02-12 | 中国平安人寿保险股份有限公司 | Abnormality eliminating method, device, computer equipment and storage medium |
-
2019
- 2019-12-25 CN CN201911353064.9A patent/CN111124734A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102981943A (en) * | 2012-10-29 | 2013-03-20 | 新浪技术(中国)有限公司 | Method and system for monitoring application logs |
US20140149978A1 (en) * | 2012-11-26 | 2014-05-29 | Oracle International Corporation | Dynamic communication between script and execution layers |
CN109325865A (en) * | 2018-08-13 | 2019-02-12 | 中国平安人寿保险股份有限公司 | Abnormality eliminating method, device, computer equipment and storage medium |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US11343305B2 (en) | 2020-09-01 | 2022-05-24 | UiPath Inc. | Systems and methods of automating a file download activity |
CN113886122A (en) * | 2021-09-30 | 2022-01-04 | 济南浪潮数据技术有限公司 | System operation exception handling method, device, equipment and storage medium |
CN113886122B (en) * | 2021-09-30 | 2024-03-01 | 济南浪潮数据技术有限公司 | System operation exception handling method, device, equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109325865B (en) | Exception handling method, exception handling device, computer equipment and storage medium | |
JP4886512B2 (en) | System and method for automated computer support | |
US8738967B2 (en) | System and method for grammar based test planning | |
JP2018142372A (en) | System and method for automated memory and thread execution anomaly detection in computer network | |
US9189317B1 (en) | Software sustaining system | |
CN111124734A (en) | Method and device for processing exception in script running process | |
CN110647451A (en) | Application program abnormity analysis method and generation method | |
US11693731B2 (en) | System and methods for diagnosing and repairing a smart mobile device by disabling components | |
CN112235342B (en) | Abnormal operation environment repairing method and device, computer equipment and storage medium | |
CN112953983A (en) | SFTP transmission method and device | |
WO2021008029A1 (en) | Case execution method, apparatus and device, and computer readable storage medium | |
US20200241947A1 (en) | Management system of storage system | |
CN112068981B (en) | Knowledge base-based fault scanning recovery method and system in Linux operating system | |
CN108255735B (en) | Associated environment testing method, electronic device and computer readable storage medium | |
CN111399862A (en) | Batch installation method and device of Windows missing driver and computer equipment | |
CN112383507A (en) | Firewall policy management method, device and system and computer readable storage medium | |
CN113050926B (en) | Method, device and equipment for confirming code synchronization change | |
US11573888B2 (en) | Machine learning test result analyzer for identifying and triggering remedial actions | |
CN110990179A (en) | Task processing method, device and equipment | |
CN111737138B (en) | Automatic recovery system and method for test environment | |
CN110515792B (en) | Monitoring method and device based on web version task management platform and computer equipment | |
US12001271B2 (en) | Network monitoring apparatus, method, and program | |
CN112787839A (en) | Port description modification method and device | |
CN116827759B (en) | Method and device for processing restarting instruction of converging current divider | |
US20230010296A1 (en) | System and method for splitting a video stream using breakpoints based on recognizing workflow patterns |
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: 20200508 |