Batch command processing method, device, medium and server of Linux system

By using Excel files and host password files to process batch commands in the Linux system, the problems of complexity and monotonous output of traditional automated operation and maintenance tools are solved, achieving user-friendly and efficient operation and maintenance operations and result display.

CN115454609BActive Publication Date: 2026-03-17E-SURFING DIGITAL LIFE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-29
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

In existing technologies, traditional automated operation and maintenance tools have complex operating procedures and limited output formats on Linux systems, which cannot meet user needs, especially for new users.

Method used

This paper provides a batch command processing method for Linux systems. By obtaining an Excel file and a host password file uploaded from a Windows client, a communication connection is established with the remote host, Linux commands are executed, automated verification is performed, and scoring results and modification suggestions are generated.

Benefits of technology

It simplifies the command operation process of Linux systems, improves user-friendliness, provides diverse output results, and helps users quickly locate problems and meet operational and maintenance needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115454609B_ABST
    Figure CN115454609B_ABST
Patent Text Reader

Abstract

The application provides a Linux system batch command processing method, device, medium and server. Before a Linux server executes a batch command on at least one remote host carrying a Linux system, the Linux server can receive an Excel file configured by a user on a Windows side. The Excel file includes an IP address of at least one remote host, a Linux command to be executed and a verification command. The user only needs to fill the IP address of the remote host, the Linux command and the verification command into the Excel file, so as to realize automatic operation and maintenance and be friendly to new users. After the Linux server receives the Excel file, a host password file of a login password of each remote host previously established can be obtained, so that the problem of low security caused by directly placing the login password in the Excel file can be avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a batch command processing method, apparatus, medium and server for a Linux system. Background Technology

[0002] Linux is an open-source, free, and freely distributed Unix-like operating system. Currently, the vast majority of enterprise application systems run on Linux, and different system applications are implemented by deploying multiple Linux systems.

[0003] In current enterprise production environments, operations and maintenance personnel often need to perform repetitive command operations on massive Linux systems. When executing these commands, they typically use open-source automated operations and maintenance tools such as Ansible or standardized automated operations and maintenance systems. However, these tools often require complex environment configurations or writing cumbersome executable files, making them unfriendly to new users and incompatible with today's fast-paced operations and maintenance work. At the same time, the output of traditional automated operations and maintenance tools (systems) is relatively simple, only able to determine whether the command was executed successfully, which cannot meet user needs. Summary of the Invention

[0004] The purpose of this application is to at least solve one of the above-mentioned technical defects, in particular the technical defect that the operation process of traditional automated operation and maintenance tools (systems) in the prior art is relatively complex and the output results are relatively simple, which cannot meet the needs of users.

[0005] This application provides a batch command processing method for a Linux system, applied to a Linux server, the method comprising:

[0006] The system retrieves an Excel file uploaded from a Windows client and a pre-created host password file. The Excel file includes the IP address of at least one remote host running a Linux system, the Linux command to be executed, and a verification command. The host password file includes the login passwords for each remote host.

[0007] Establish communication connections with each remote host, and after establishing the communication connection, log in to the corresponding remote host using the login password of each remote host, and execute the corresponding Linux command on each remote host according to the execution order of each Linux command in the Excel file;

[0008] After obtaining the first execution result returned after executing the corresponding Linux command on each remote host, and automatically verifying the first execution result according to the verification command, the verification result includes the score result of the first execution result and the modification suggestions;

[0009] The verification results are sent to the Windows client for display, allowing users to view the scoring results and suggestions for improvement.

[0010] Optionally, obtaining the Excel file uploaded from the Windows client includes:

[0011] The first encrypted file uploaded from the Windows client is obtained, and the first encrypted file is decrypted according to the pre-agreed first decryption method to obtain an Excel file;

[0012] The first encrypted file is an encrypted file formed by the user filling in the IP address of the remote host, the Linux command to be executed, and the verification command in a preset Excel template file. The Excel template file comes with a library of commonly used Linux commands and syntax hints.

[0013] Optionally, obtaining the pre-created host password file includes:

[0014] Obtain a pre-created second encrypted file containing the login passwords of each remote host, and decrypt the second encrypted file according to a pre-agreed second decryption method to obtain the host password file.

[0015] Optionally, the first execution result includes the first return code obtained after executing system commands on each remote host, the first standard output captured after executing Linux commands on each remote host, and the first standard output captured.

[0016] The step of automatically verifying the first execution result according to the verification command to obtain the verification result includes:

[0017] Obtain a pre-established standard library, which stores the second no-standard output captured after executing Linux commands on each test host, as well as the standard files and standard results obtained when capturing the second no-standard output;

[0018] Acquire the first target file and the first prediction result obtained when capturing the first target file without standard output, compare the similarity of the first target file with the standard file in the standard library to obtain the first comparison result, and filter out and record the result keywords from the first target file;

[0019] After comparing the first prediction result with the standard result according to the verification command, a second comparison result is obtained;

[0020] Parse the first return code and record the parsing result of the first return code;

[0021] Filter out and record error flags from the first standard output;

[0022] The first execution result is comprehensively scored based on the first comparison result, the second comparison result, and various records, and corresponding modification suggestions are configured for the deduction items in the scoring result;

[0023] The scoring results and the suggested modifications will be used as the verification results.

[0024] Optionally, the step of comprehensively scoring the first execution result based on the first comparison result, the second comparison result, and various records includes:

[0025] Determine the first score percentage of the first comparison result, the second score percentage of the second comparison result, and the third score percentage of each record;

[0026] Based on the first comparison result, the first score percentage, the second comparison result, the second score percentage, each record, and the third score percentage, the comprehensive score of the first execution result is calculated.

[0027] Optionally, the process of establishing the standard library includes:

[0028] Select a portion of the remote hosts in the Excel file as test hosts, and select the login password corresponding to each test host from the host password file;

[0029] Establish communication connections with each test host, and after establishing the communication connection, log in to the corresponding test host using the login password of each test host, and execute the corresponding Linux commands on each test host according to the execution order of each Linux command in the Excel file;

[0030] Obtain the second execution result returned after executing the corresponding Linux command on each test host, and generate the standard library corresponding to the second execution result.

[0031] Optionally, the second execution result includes the second return code obtained after executing system commands on each test host, and the second standard output and the second standard output captured after executing Linux commands on each test host;

[0032] The generation of the standard library corresponding to the second execution result includes:

[0033] Obtain the second target file and the second prediction result when capturing the second target file without standard output, and use the second target file as the standard file and the second prediction result as the standard result;

[0034] An initial standard library is generated based on the standard file, the standard result, the second return code, and the second standard output.

[0035] The initial standard library is sent to the Windows client for display, and the user's confirmation of the initial standard library is obtained. The final standard library is generated based on the confirmation result.

[0036] This application also provides a batch command processing device for a Linux system, including:

[0037] The parameter acquisition module is used to acquire the Excel file uploaded by the Windows client and the pre-created host password file. The Excel file includes the IP address of at least one remote host running a Linux system, the Linux command to be executed, and the verification command. The host password file includes the login password of each remote host.

[0038] The batch command execution module is used to establish communication connections with each remote host, and after establishing the communication connection, log in to the corresponding remote host using the login password of each remote host, and execute the corresponding Linux command on each remote host according to the execution order of each Linux command in the Excel file.

[0039] The execution result verification module is used to obtain the first execution result returned after executing the corresponding Linux command on each remote host, and to automatically verify the first execution result according to the verification command to obtain the verification result. The verification result includes the score result of the first execution result and the modification suggestions.

[0040] The verification result display module is used to send the verification results to the Windows terminal for display, so that users can view the scoring results and modification suggestions in the verification results.

[0041] This application also provides a storage medium storing computer-readable instructions that, when executed by one or more processors, cause the one or more processors to perform the steps of the batch command processing method of the Linux system as described in any of the above embodiments.

[0042] This application also provides a Linux server, including: one or more processors, and memory;

[0043] The memory stores computer-readable instructions, which, when executed by the one or more processors, perform the steps of the batch command processing method of the Linux system as described in any of the above embodiments.

[0044] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:

[0045] The batch command processing method, apparatus, medium, and server for Linux systems provided in this application allow the Linux server to receive an Excel file configured by the user on the Windows side before executing batch commands on at least one remote host running a Linux system. This Excel file includes the IP address of at least one remote host, the Linux command to be executed, and a verification command. The user only needs to fill in the IP address of the remote host to be executed, the Linux command, and the verification command into the Excel file to achieve automated operation and maintenance, which is user-friendly for new users. After receiving the Excel file, the Linux server can obtain a pre-established host password file containing the login passwords of each remote host, and after establishing communication connections with each remote host, execute batch commands through each remote host. The login password for the remote host is used to log in to the corresponding remote host. This avoids the security risks associated with directly storing the login password in an Excel file. After logging into the remote host, the Linux server executes the corresponding Linux commands on each remote host according to the execution order in the Excel file. It then obtains the first execution result returned after executing the corresponding Linux commands on each remote host, performs automated verification on the first execution result according to the verification command, and sends the verification result to the Windows client for display. The user can check whether the first execution result meets the user's expectations based on the rating and modification suggestions in the verification result. The modification suggestions can also help the user better locate and handle problems, thereby meeting the user's needs. Attached Figure Description

[0046] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0047] Figure 1 A flowchart illustrating a batch command processing method for a Linux system provided in an embodiment of this application;

[0048] Figure 2A schematic diagram illustrating the layout of the Excel spreadsheet provided in this embodiment of the application;

[0049] Figure 3 This is a schematic diagram illustrating the process of automatically verifying the first execution result provided in an embodiment of this application;

[0050] Figure 4 A schematic diagram of the structure of a batch command processing device for a Linux system provided in an embodiment of this application;

[0051] Figure 5 This is a schematic diagram of the internal structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0052] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0053] In current enterprise production environments, operations and maintenance (O&M) personnel frequently need to perform repetitive command operations on massive Linux systems. When executing these commands, they typically use open-source automated O&M tools such as Ansible or standardized automated O&M systems. However, these tools often require complex environment configurations or writing cumbersome executable files, making them unfriendly to new users and incompatible with today's fast-paced O&M work. Furthermore, the output of traditional automated O&M tools (systems) is relatively simple, only providing basic information on command execution success, failing to meet user needs. Based on this, this application proposes the following technical solution, detailed below:

[0054] In one embodiment, such as Figure 1 As shown, Figure 1 This application provides a flowchart illustrating a batch command processing method for a Linux system, applicable to a Linux server. The method may include:

[0055] S110: Retrieves the Excel file uploaded from the Windows client and the pre-created host password file.

[0056] In this step, before executing batch commands on at least one remote host running Linux, the Linux server can first obtain an Excel file uploaded by the Windows client. This Excel file is edited by the user in the Windows interface. During editing, the user can call the Excel template file and fill in the corresponding parameters using the preset formatting in the Excel template file. In this way, the process of writing complex command execution files (such as writing Ansible YAML files) can be transformed into an Excel spreadsheet format. It combines the advantages of Linux command line execution and Windows office visualization, greatly reducing the difficulty of Linux batch command execution. Moreover, it is more portable, more scalable, and has a wider range of applications.

[0057] In one specific implementation, the parameters filled in this application may include the IP address of at least one remote host, the Linux command to be executed, and a verification command. Specifically, the IP address of the remote host in this application can be an IPv4 address, such as 192.168.1.12; the Linux command to be executed refers to the specific command to be executed on the remote host running a Linux system, which may include system commands or other specified commands; and the verification command refers to the command used to verify the expected result obtained after executing the Linux command.

[0058] Furthermore, different parameters in an Excel file can be arranged in columns, as illustrated below. Figure 2 As shown, Figure 2 This is a schematic diagram illustrating the layout of the Excel table provided in the embodiments of this application; by Figure 2 As can be seen, this application allows users to fill in the IP address of the remote host in the first column of an Excel spreadsheet, the Linux command to be executed in the second column, and the verification command in the third column. The completed Excel spreadsheet can then be uploaded to the Linux server as an Excel file. In addition, this application can encrypt the Excel spreadsheet before uploading to further enhance the security of data transmission.

[0059] Furthermore, in this application, after the Linux server obtains the Excel file uploaded by the Windows client, it can also obtain a pre-created host password file through the IP address of the remote host in the Excel file. The host password file includes the login password of each remote host, which can be used to log in to the remote host before executing Linux commands on the remote host. Moreover, this application stores the login password of the remote host separately from the IP address of the remote host, the Linux command to be executed, etc., which is more conducive to improving data security.

[0060] S120: Establish communication connections with each remote host, and after establishing the communication connection, log in to the corresponding remote host using the login password of each remote host, and execute the corresponding Linux command on each remote host according to the execution order of the Linux commands in the Excel file.

[0061] In this embodiment, after obtaining the Excel file uploaded by the Windows client and the pre-created host password file through S110, the Linux server first connects to the corresponding remote host before executing the Linux command, and then executes the corresponding Linux command on each remote host according to the execution order of each Linux command in the Excel file.

[0062] Specifically, in this application, when the Linux server connects to a remote host, it can first call a Python program and use the Python program to establish communication connections between the Linux server and each remote host. For example, this application can use the paramiko module in the Python program to implement the SSHv2 protocol. With the Paramiko module, the SSH protocol can be used directly in the Python program to perform related operations on the remote host, such as logging into the corresponding remote host using the login password of each remote host, and executing the corresponding Linux command on each remote host according to the execution order of the Linux commands in the Excel file.

[0063] Since the Excel file of this application contains at least one Linux command to be executed on a remote host, when there is only one remote host, this application can execute the corresponding Linux commands sequentially according to the execution order of the Linux commands corresponding to the remote host filled in the Excel file; when there are two or more remote hosts, this application can first determine the Linux command to be executed corresponding to each remote host in the Excel file, and then execute the corresponding Linux commands sequentially according to the execution order of the Linux commands corresponding to each remote host, so as to realize the scheme of executing batch commands on multiple remote hosts at the same time.

[0064] S130: Obtain the first execution result returned after executing the corresponding Linux command on each remote host, and obtain the verification result by automatically verifying the first execution result according to the verification command.

[0065] In this step, after the Linux commands are executed on each remote host in the order of execution of the Linux commands in the Excel file by S120, the Linux server can obtain the first execution result returned after executing the corresponding Linux commands on each remote host, and then automatically verify the first execution result according to the verification command to obtain the verification result.

[0066] Specifically, after obtaining the first execution result returned after executing the corresponding Linux commands on each remote host, this application can use a Python program to record the relevant output generated during the execution of the Linux commands. Then, a built-in algorithm in the Python program is used for data analysis to obtain the final verification result. This verification result can include the score of the first execution result and suggestions for improvement, thereby achieving a comprehensive score and error location for the first execution result. Based on the user's error history, modification suggestions are provided for the user's reference, helping the user better locate problems and effectively improving the customer experience.

[0067] S140: Send the verification results to the Windows client for display, so that users can view the scoring results and modification suggestions in the verification results.

[0068] In this step, after obtaining the verification result through S130, the Linux server can send the verification result to the Windows client for display, so that users can view the specific verification result on the Windows client, determine whether the current first execution result meets expectations based on the scoring result in the verification result, and locate specific problems based on the modification suggestions in the verification result, so as to quickly implement operation and maintenance services.

[0069] Furthermore, in this application, the Linux server can output the verification results to the screen and save them as an Excel file. In addition, after obtaining the verification results, the Linux server can automatically clear temporary files and environment variables generated during the process to free up space.

[0070] In the above embodiments, before executing batch commands on at least one remote host running a Linux system, the Linux server can receive an Excel file configured by the user on the Windows side. This Excel file includes the IP address of at least one remote host, the Linux command to be executed, and a verification command. The user only needs to fill in the IP address of the remote host to be executed, the Linux command, and the verification command into the Excel file to achieve automated operation and maintenance, which is user-friendly for new users. After receiving the Excel file, the Linux server can obtain a pre-established host password file containing the login passwords for each remote host, and after establishing communication connections with each remote host, log in to the corresponding remote host using its login password. This method uses a remote host, avoiding the security risks associated with storing login passwords directly in an Excel file. After logging into the remote host, the Linux server executes the corresponding Linux commands for each remote host in the order listed in the Excel file. It then retrieves the first execution result returned after executing the commands for each remote host, performs automated verification on this first result according to a verification command, and sends the verification result to the Windows client for display. Users can then check whether the first execution result meets their expectations based on the rating and suggested modifications in the verification result. These modifications can also help users better locate and resolve problems, thereby meeting their needs.

[0071] In one embodiment, obtaining the Excel file uploaded from the Windows client in S110 may include: obtaining the first encrypted file uploaded from the Windows client, and decrypting the first encrypted file according to a pre-agreed first decryption method to obtain the Excel file.

[0072] The first encrypted file is an encrypted file formed by the user filling in the IP address of the remote host, the Linux command to be executed, and the verification command in a preset Excel template file. The Excel template file comes with a library of commonly used Linux commands and syntax hints.

[0073] In this embodiment, for security reasons, the Excel file uploaded by the Windows client and obtained by the Linux server can be a first encrypted file. The first encrypted file is an encrypted file obtained by encrypting the Excel file. After obtaining the first encrypted file, the Linux server can decrypt the first encrypted file according to the pre-agreed first decryption method to obtain the Excel file.

[0074] Furthermore, in this application, when users edit the IP address of a remote host, the Linux command to be executed, verification commands, etc., in the Windows interface, they can input them into a preset Excel template file to complete the writing of the executable file. Simultaneously, users can also utilize the preset Linux common command library in the Excel template file and the built-in suggestion function of Excel spreadsheets to achieve automatic completion and syntax hints during the command editing process, further improving the user's editing efficiency.

[0075] In one embodiment, obtaining the pre-created host password file in S110 may include: obtaining a pre-created second encrypted file containing the login passwords of each remote host, and decrypting the second encrypted file according to a pre-agreed second decryption method to obtain the host password file.

[0076] In this embodiment, for security reasons, when the Linux server creates the host password file, it can encrypt the host password file to form a second encrypted file. When the second encrypted file is subsequently obtained, it can be decrypted according to a pre-agreed second decryption method to obtain the host password file.

[0077] In one embodiment, such as Figure 3 As shown, Figure 3 This is a schematic diagram of the process of automatically verifying the first execution result provided in an embodiment of this application; the first execution result may include the first return code obtained after executing system commands on each remote host, the first standard output captured after executing Linux commands on each remote host, and the first standard output captured.

[0078] S130, after automatically verifying the first execution result according to the verification command, may obtain a verification result, which may include:

[0079] S131: Obtain a pre-established standard library, which stores the second no-standard output captured after executing Linux commands on each test host, as well as the standard file and standard results obtained when capturing the second no-standard output.

[0080] S132: Obtain the first target file and the first prediction result obtained when capturing the first target file without standard output, and compare the similarity of the first target file with the standard file in the standard library to obtain the first comparison result, and filter out the result keywords from the first target file and record them.

[0081] S133: After comparing the first prediction result with the standard result according to the verification command, a second comparison result is obtained.

[0082] S134: Parse the first return code and record the parsing result of the first return code.

[0083] S135: Filter out and record error flags from the first standard output.

[0084] S136: Based on the first comparison result, the second comparison result, and various records, the first execution result is comprehensively scored, and corresponding modification suggestions are configured for the deduction items in the scoring result.

[0085] S137: The scoring results and the proposed modifications shall be used as the verification results.

[0086] In this embodiment, when obtaining the verification result after automatically verifying the first execution result according to the verification command, this application can use a pre-established standard library and verification command to analyze multiple indicators, realize the automated verification of the first execution result, and put forward corresponding improvement suggestions to help users better locate problems.

[0087] Specifically, when executing Linux commands on remote hosts, this application utilizes the `subprocess` module in Python to call Linux shell commands and return status and results. The `subprocess` module can contain various functions, such as `subprocess.run()`, `subprocess.check_call()`, `subprocess.check_output()`, and `subprocess.getoutput(cmd)`. `subprocess.run()` executes the specified command and returns an instance of the `CompletedProcess` class containing the execution result after the command completes. `subprocess.check_call()` executes the specified command; if successful, it returns a status code; otherwise, it throws an exception. `subprocess.check_output()` executes the specified command; if the execution status code is 0, it returns the command execution result; otherwise, it throws an exception. `subprocess.getoutput(cmd)` receives a string-formatted command, executes it, and returns the execution result. Based on this, this application can categorize the first execution result into three main types of output: the first return code obtained after executing a system command, the first output with standard output captured after executing a Linux command, and the first output without standard output.

[0088] Furthermore, after obtaining the first execution result of this application, the Linux server can obtain a pre-established standard library, which stores the second no-standard output captured after executing Linux commands on each test host, as well as the standard file and standard result obtained when capturing the second no-standard output. After obtaining the standard library, the Linux server can continue to obtain the first target file and first prediction result obtained when capturing the first no-standard output, and compare them with the data in the standard library to obtain the comparison result.

[0089] Indicatively, such as Figure 3 As shown, this application can parse the first return code obtained after executing system commands on each remote host and record the parsing result of the first return code, such as a first return code of 0. Next, this application can filter out error identifiers from the first standard output and record them. Of course, this application can also perform a similarity comparison between the first target file and standard files in the standard library to obtain a first comparison result, filter out result keywords from the first target file and record them, and compare the first prediction result with the standard result according to the verification command to obtain a second comparison result. After obtaining each comparison result and each record, this application can comprehensively score the first execution result based on the first comparison result, the second comparison result, and each record, and configure corresponding modification suggestions for the deduction items in the scoring result. Finally, the scoring result and the modification suggestions are used as the verification result.

[0090] For example, when comparing the similarity of the first target file with the standard files in the standard library, this application can use diff verification and MD5 verification to perform similarity comparison and provide scoring conditions. For example, when using diff verification, a similarity of more than 90% is a full score, while a similarity of less than 90% can be scored according to the specific similarity score; while when using MD5 verification, a perfect match is a full score, and if the similarity is less than 100%, the score is based on the specific similarity score. When scoring the parsing result of the first return code, a score of 0 is given if the first return code is 0, and 0 if it is not 0. When scoring the error identifiers filtered out from the first standard output, a score of 0 is given if there are no error identifiers, and a score based on the number of error identifiers if there are error identifiers. The fewer error identifiers, the higher the score, and the more error identifiers, the lower the score. When scoring the result keywords filtered out from the first target file, a higher score is given if there are more result keywords, and a lower score is given if there are fewer result keywords. When scoring the second comparison result obtained by comparing the first prediction result with the standard result according to the verification command, a score of 0 is given for consistent comparison results, a high score is given for results with small differences, and a low score is given for results with large differences. This is how the comprehensive score of the first execution result is obtained.

[0091] After obtaining the overall score, if there are deductions in the score results, this application can also configure corresponding modification suggestions for the deductions in the score results. For example, when scoring the error identifiers filtered out from the first standard output, if there are no error identifiers, the score is full; if there are error identifiers, the score is based on the number of error identifiers. Since the location and number of error identifiers are recorded during scoring, when an error identifier causes a deduction, reasonable modification suggestions can be given based on the specific location of the error identifier to help the user locate the problem.

[0092] In one embodiment, the comprehensive scoring of the first execution result based on the first comparison result, the second comparison result, and various records in S136 may include:

[0093] S1361: Determine the first score percentage of the first comparison result, the second score percentage of the second comparison result, and the third score percentage of each record.

[0094] S1362: Calculate the comprehensive score of the first execution result based on the first comparison result, the first score ratio, the second comparison result, the second score ratio, each record, and the third score ratio.

[0095] In this embodiment, when performing a comprehensive score on the first execution result, this application can first determine the first comparison result, the second comparison result, and the individual scores of each record, then determine the first score percentage of the first comparison result, the second score percentage of the second comparison result, and the third score percentage of each record, and calculate the comprehensive score of the first execution result based on the first comparison result, the first score percentage, the second comparison result, the second score percentage, each record, and the third score percentage.

[0096] like Figure 3 As shown, this application can set the first score percentage of the first comparison result to 15%, the second score percentage of the second comparison result to 40%, and the third score percentage of each record to 45%, thereby calculating the comprehensive score of the first execution result.

[0097] In one embodiment, the process of creating the standard library may include:

[0098] S101: Select a portion of the remote hosts in the Excel file as test hosts, and select the login password corresponding to each test host from the host password file.

[0099] S102: Establish communication connections with each test host respectively, and after establishing the communication connection, log in to the corresponding test host using the login password of each test host, and execute the corresponding Linux command on each test host according to the execution order of each Linux command in the Excel file.

[0100] S103: Obtain the second execution result returned after executing the corresponding Linux command on each test host, and generate the standard library corresponding to the second execution result.

[0101] In this embodiment, when building the standard library, the Linux server can use the test module in the Python program to automatically read the Excel file and execute Linux commands to generate the standard library.

[0102] Specifically, the testing module can select a portion of remote hosts in the Excel file as test hosts, and select login passwords corresponding to each test host from the host password file. Then, it establishes communication connections with each test host, and logs in to the corresponding test host using the login password. Then, it executes the corresponding Linux commands on each test host according to the execution order of the Linux commands in the Excel file. Finally, it obtains the second execution result returned after executing the corresponding Linux commands on each test host, and generates a standard library corresponding to the second execution result. This standard library can be used for automated verification of the first execution result.

[0103] In one embodiment, the second execution result may include a second return code obtained after executing system commands on each test host, and a second output with standard and a second output without standard captured after executing Linux commands on each test host.

[0104] S103 may include generating a standard library corresponding to the second execution result, which may include:

[0105] S1031: Obtain the second target file and the second prediction result obtained when capturing the second target file without standard output, and use the second target file as the standard file and the second prediction result as the standard result.

[0106] S1032: Generate an initial standard library based on the standard file, the standard result, the second return code, and the second standard output.

[0107] S1033: Send the initial standard library to the Windows terminal for display, obtain the user's confirmation result of the initial standard library, and generate the final standard library based on the confirmation result.

[0108] In this embodiment, when generating the standard library, the second target file and the second prediction result obtained when capturing the second no-standard output can be used as the standard file and standard result, respectively. An initial standard library is generated based on the standard file, the standard result, the second return code obtained after executing system commands on each test host, and the second standard output captured after executing Linux commands on each test host. Then, the Linux server can send the initial standard library to the Windows client for display so that the user can read and confirm it. Once the user confirms it, the initial standard library becomes the final standard library.

[0109] Of course, users can also modify the information in the initial standard library during the confirmation process. For example, users can personalize the standard results according to their own needs, thereby improving efficiency.

[0110] The batch command processing apparatus for the Linux system provided in the embodiments of this application is described below. The batch command processing apparatus for the Linux system described below can be referred to in correspondence with the batch command processing method for the Linux system described above.

[0111] In one embodiment, such as Figure 4 As shown, Figure 4 This application provides a schematic diagram of a batch command processing device for a Linux system, as shown in an embodiment of the present application. The present application also provides a batch command processing device for a Linux system, which may include a parameter acquisition module 210, a batch command execution module 220, an execution result verification module 230, and a verification result display module 240, specifically including the following:

[0112] The parameter acquisition module 210 is used to acquire an Excel file uploaded by the Windows client and a pre-created host password file. The Excel file includes the IP address of at least one remote host running a Linux system, the Linux command to be executed, and a verification command. The host password file includes the login password of each remote host.

[0113] The batch command execution module 220 is used to establish communication connections with each remote host, and after establishing the communication connection, log in to the corresponding remote host using the login password of each remote host, and execute the corresponding Linux command on each remote host according to the execution order of each Linux command in the Excel file.

[0114] The execution result verification module 230 is used to obtain the first execution result returned after executing the corresponding Linux command on each remote host, and to automatically verify the first execution result according to the verification command to obtain the verification result. The verification result includes the score result of the first execution result and the modification suggestions.

[0115] The verification result display module 240 is used to send the verification result to the Windows terminal for display, so that users can view the scoring results and modification suggestions in the verification result.

[0116] In the above embodiments, before executing batch commands on at least one remote host running a Linux system, the Linux server can receive an Excel file configured by the user on the Windows side. This Excel file includes the IP address of at least one remote host, the Linux command to be executed, and a verification command. The user only needs to fill in the IP address of the remote host to be executed, the Linux command, and the verification command into the Excel file to achieve automated operation and maintenance, which is user-friendly for new users. After receiving the Excel file, the Linux server can obtain a pre-established host password file containing the login passwords for each remote host, and after establishing communication connections with each remote host, log in to the corresponding remote host using its login password. This method uses a remote host, avoiding the security risks associated with storing login passwords directly in an Excel file. After logging into the remote host, the Linux server executes the corresponding Linux commands for each remote host in the order listed in the Excel file. It then retrieves the first execution result returned after executing the commands for each remote host, performs automated verification on this first result according to a verification command, and sends the verification result to the Windows client for display. Users can then check whether the first execution result meets their expectations based on the rating and suggested modifications in the verification result. These modifications can also help users better locate and resolve problems, thereby meeting their needs.

[0117] In one embodiment, this application also provides a storage medium storing computer-readable instructions that, when executed by one or more processors, cause the one or more processors to perform the steps of the batch command processing method of the Linux system as described in any of the above embodiments.

[0118] In one embodiment, this application also provides a Linux server, including one or more processors and memory.

[0119] The memory stores computer-readable instructions, which, when executed by the one or more processors, perform the steps of the batch command processing method of the Linux system as described in any of the above embodiments.

[0120] Indicatively, such as Figure 5 As shown, Figure 5This is a schematic diagram of the internal structure of a computer device 300 provided in an embodiment of this application. The computer device 300 can be provided as a Linux server. (Refer to...) Figure 5 The computer device 300 includes a processing component 302, which further includes one or more processors, and memory resources represented by memory 301 for storing instructions, such as application programs, that can be executed by the processing component 302. The application programs stored in memory 301 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 302 is configured to execute instructions to perform the batch command processing method of the Linux system described in any of the above embodiments.

[0121] The computer device 300 may also include a power supply component 303 configured to perform power management of the computer device 300, a wired or wireless network interface 304 configured to connect the computer device 300 to a network, and an input / output (I / O) interface 305. The computer device 300 may operate on an operating system, such as Linux™ or similar, stored in memory 301.

[0122] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0123] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0124] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referred to each other.

[0125] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for processing batch commands of a Linux system, applied to a Linux server, characterized in that, The method comprises: obtaining an Excel file uploaded by a Windows end and a host password file created in advance, the Excel file comprising an IP address of at least one remote host carrying a Linux system, a Linux command to be executed and a check command, and the host password file comprising a login password of each remote host; respectively establishing a communication connection with each remote host, logging into the corresponding remote host through the login password of each remote host after the communication connection is established, and executing the corresponding Linux command on each remote host according to the execution order of each Linux command in the Excel file; obtaining a first execution result returned after the corresponding Linux command is executed on each remote host, and obtaining a check result after the first execution result is automatically checked according to the check command, the check result comprising a score result of the first execution result and a modification suggestion; issuing the check result to the Windows end for display, so that a user can view the score result and the modification suggestion in the check result; the first execution result comprises a first return code obtained after a system command is executed on each remote host, a first standard output captured after a Linux command is executed on each remote host, and a first non-standard output; the check result obtained after the first execution result is automatically checked according to the check command comprises: obtaining a standard library established in advance, the standard library storing a second non-standard output captured after a Linux command is executed on each test host, a standard file and a standard result obtained when the second non-standard output is captured; obtaining a first target file and a first prediction result obtained when the first non-standard output is captured, comparing the first target file with the standard file in the standard library to obtain a first comparison result, and filtering a result keyword from the first target file and recording the result keyword; comparing the first prediction result with the standard result according to the check command to obtain a second comparison result; analyzing the first return code and recording the analysis result of the first return code; filtering an error identifier from the first standard output and recording the error identifier; comprehensively scoring the first execution result according to the first comparison result, the second comparison result and each record, and configuring a corresponding modification suggestion for a deduction item in the score result; the score result and the modification suggestion are taken as the check result.

2. The Linux system batch command processing method of claim 1, wherein, The Excel file uploaded by the Windows end comprises: obtaining a first encrypted file uploaded by the Windows end, and decrypting the first encrypted file according to a first decryption method agreed in advance to obtain an Excel file; wherein the first encrypted file is an encrypted file formed after a user fills in an IP address of a remote host, a Linux command to be executed and a check command in a preset Excel template file, and the Excel template file is self-provided with a Linux common command library and a syntax prompt function.

3. The Linux system batch command processing method of claim 1, wherein, The host password file created in advance comprises: Obtain a second encryption file containing login passwords of the remote hosts created in advance, and decrypt the second encryption file according to a second decryption mode agreed in advance to obtain a host password file.

4. The Linux system batch command processing method of claim 1, wherein, The comprehensive score of the first execution result according to the first comparison result, the second comparison result and each record includes: The first score proportion of the first comparison result, the second score proportion of the second comparison result and the third score proportion of each record are determined. The comprehensive score of the first execution result is calculated according to the first comparison result, the first score proportion, the second comparison result, the second score proportion, each record and the third score proportion.

5. The Linux system batch command processing method of claim 1, wherein, The establishment process of the standard library includes: Some remote hosts in the Excel file are selected as test hosts, and login passwords corresponding to each test host are selected from the host password file; Communication connections with each test host are established respectively, and after the communication connections are established, the corresponding test host is logged in through the login password of each test host, and each test host is executed according to the execution order of each Linux command in the Excel file. Second execution results returned after each test host is executed with the corresponding Linux command are obtained, and a standard library corresponding to the second execution result is generated.

6. The Linux system batch command processing method of claim 5, wherein, The second execution result includes a second return code obtained after each test host is executed with a system command, a second standard output and a second non-standard output captured after each test host is executed with a Linux command; The generation of the standard library corresponding to the second execution result includes: A second target file and a second prediction result obtained when the second non-standard output is captured are obtained, and the second target file is taken as a standard file and the second prediction result is taken as a standard result; An initial standard library is generated according to the standard file, the standard result, the second return code and the second standard output; The initial standard library is sent to the Windows end for display, and a confirmation result of the initial standard library is obtained, and a final standard library is generated according to the confirmation result.

7. A batch command processing apparatus of a Linux system, characterized by comprising: It includes: The parameter acquisition module is used for obtaining the Excel file uploaded by the Windows end and the host password file created in advance, the Excel file including the IP address of at least one remote host equipped with a Linux system, a Linux command to be executed and a verification command, and the host password file including login passwords of each remote host; The batch command execution module is used for establishing communication connections with each remote host respectively, and after the communication connections are established, the corresponding remote host is logged in through the login password of each remote host, and each remote host is executed according to the execution order of each Linux command in the Excel file. The execution result checking module is configured to obtain a first execution result returned after executing a corresponding Linux command on each remote host, and obtain a checking result by automatically checking the first execution result according to the checking command, wherein the checking result includes a score result of the first execution result and a modification suggestion; The checking result display module is configured to send the checking result to the Windows terminal for display, so that a user can view the score result and the modification suggestion in the checking result; The first execution result includes a first return code obtained after executing a system command on each remote host, a first standard output captured after executing a Linux command on each remote host, and a first non-standard output; The execution result checking module obtains a checking result by automatically checking the first execution result according to the checking command, including: Obtaining a standard library established in advance, wherein the standard library stores a second non-standard output captured after executing a Linux command on each test host, a standard file, and a standard result obtained when the second non-standard output is captured; Obtaining a first target file and a first prediction result obtained when the first non-standard output is captured, comparing the first target file with the standard file in the standard library to obtain a first comparison result, and filtering a result keyword from the first target file and recording the result keyword; Comparing the first prediction result with the standard result according to the checking command to obtain a second comparison result; Analyzing the first return code and recording an analysis result of the first return code; Filtering an error identifier from the first standard output and recording the error identifier; According to the first comparison result, the second comparison result, and the records, a comprehensive score of the first execution result is obtained, and a corresponding modification suggestion is configured for a deduction item in the score result; The score result and the modification suggestion are taken as the checking result.

8. A storage medium characterized by: The storage medium stores computer readable instructions, and the computer readable instructions are executed by one or more processors to make the one or more processors execute the steps of the Linux system batch command processing method in any one of claims 1 to 6.

9. A Linux server, characterized in that Including: One or more processors, and a memory; The memory stores computer readable instructions, and the computer readable instructions are executed by the one or more processors to execute the steps of the Linux system batch command processing method in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method and system for testing network pressure of PXK1 video accelerator card

    CN110750398A

  • Batch automatic operation and maintenance management method for operating system

    CN110955457A