Web system capable of predicting user input and connected with remote Linux / Unix

Through the Web-based remote Linux/Unix connection system and command input prediction function, the user's interface inconsistency and cumbersome command input problems when operating remote servers are solved, and the effect of simplifying operations and improving efficiency is achieved.

CN119135678APending Publication Date: 2024-12-13张占波
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411366454.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

When connecting and operating remote Linux/Unix servers, users need to remember and input a large number of commands, and the interfaces of different SSH clients are inconsistent, resulting in inconvenient operation and error-prone.

Method used

A web-based system has been developed, where users can connect to remote Linux/Unix servers without installing a client, operate through browser operations, and use historical commands to analyze and predict user input habits, provide command input prediction functions, and simplify operation flow.

Benefits of technology

It realizes a unified cross-platform operation interface, reduces the time and error rate of command input, and improves user experience and operation efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119135678A_ABST
    Figure CN119135678A_ABST
Patent Text Reader

Abstract

The invention discloses a Web system capable of predicting user input and connected with remote Linux / Unix. According to user command input history, user habits are analyzed and extracted, a user command input habit model is constructed, and user input is predicted through the habit model. The construction method of the command input habit model comprises the following steps: splitting a historical input command of a user; generating a mode for the command; analyzing the relevance of the command before and after the command; generating a conversation according to the command; and generating dialogue parameters according to the dialogue, so that the command input habit model comprises a command mode, the dialogue and the dialogue parameters. According to letters input when a user inputs a command, according to the command input habit model, and according to matching of a mode, a dialogue and / or dialogue parameters, predicting and giving a command which may be input.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of computer technology, and in particular relates to a Web system capable of predicting user input and connecting to a remote Linux / Unix. Background Art

[0002] SSH client allows users to securely access remote computers through the SSH (Secure Shell) protocol. SSH is an encrypted network protocol used to securely access and control remote servers over an insecure network. Users use SSH clients to execute commands on remote servers as if they were operating directly on the server. SSH clients usually support secure file transfers using protocols such as SCP (Secure Copy) or SFTP (Secure File Transfer Protocol). SSH clients can create secure tunnels to forward ports from local computers to remote servers for secure access to remote services. SSH supports a variety of authentication methods, including passwords, public / private key pairs, and one-time passwords. SSH clients can run on a variety of operating systems, including Windows, macOS, Linux, and more. SSH clients can be used in conjunction with scripts to automate remote task execution. SSH client is an important tool for system administrators, developers, and anyone who needs to access servers remotely. It improves the security and convenience of remote work.

[0003] As a popular operating system, Linux / Unix is ​​widely used in all walks of life. Linux / Unix can be found in physical machines, virtual machines, and popular cloud services. Usually, if a user wants to connect to a Linux / Unix machine, he or she will first install an SSH client on the local machine, and then use the client to establish a connection with the remote machine. If the user changes to another machine to connect to the remote machine, the user must also install the SSH client and make various configurations. Moreover, there are many types of SSH clients, and different client behavior interfaces and functions may be different, which brings great inconvenience to users.

[0004] In addition, users mostly interact with the target Linux / Unix through commands. There are many Linux / Unix commands, and there are even more commands for various software installed in Linux / Unix. It is difficult for users to remember these commands accurately. In many cases, the commands to be entered are very long, and the system does not prompt for manual input, making command input very time-consuming and error-prone. Even if users search for the command input history, it takes a long time to find it. Summary of the invention

[0005] One of the embodiments of the present disclosure is a system for connecting to a remote Linux / Unix based on a Web. Users do not need to install any client. Even on different clients, users can log in to the system and connect to the target Linux / Unix as long as they have a browser. This makes all the operation interfaces the same on different machines, and no additional learning is required. You can either connect to the target machine through SSH to operate through commands, or connect to the target machine through SFTP to manipulate files on the target machine through the interface, and you can transfer files between different machines.

[0006] One of the embodiments of the present disclosure is a method for providing predictions to a user based on the user's historical commands. The method analyzes the user's historical commands, extracts the user's input habits, builds a model, and then provides predictions for the user's new command input.

[0007] The disclosed embodiment calculates the user's input habits based on the historical commands input by the user, and then predicts the user's possible input. Unlike complex natural language processing large models, this system has the advantages of being explainable, predictable, analyzable, simple and lightweight. The amount of data required, the space occupied, and the performance are significantly superior to the existing ones. BRIEF DESCRIPTION OF THE DRAWINGS

[0008] The above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, in which:

[0009] Figure 1 A remote Linux connection based on Web according to one embodiment of the present invention server Schematic diagram of the system structure.

[0010] Figure 2 A flow chart of pattern generation in a command input prediction method according to one embodiment of the present invention.

[0011] Figure 3 A flowchart of command association analysis of a command input prediction method according to one embodiment of the present invention.

[0012] Figure 4 A flow chart of a dialog generation method for command input prediction according to one embodiment of the present invention.

[0013] Figure 5 A flow chart of dialog parameter generation in a command input prediction method according to one embodiment of the present invention. DETAILED DESCRIPTION

[0014] According to one or more embodiments, Figure 1 As shown, based on the Web connection remote Linux server The system structure diagram is shown in Figure 1. The system is mainly composed of a proxy server, a session server, a computing server and a database. The proxy server mainly performs the diversion function, that is, it distributes different requests of users to different servers for processing. The session server mainly maintains the SSH / SFTP connection with Linux and responds to user commands or file requests. The computing server is mainly responsible for analyzing user commands, generating mode dialogues, predicting user commands, etc. The database is used to store various data required for system operation.

[0015] The user establishes an HTTP connection with the proxy server through the browser to realize data request and response. Alternatively, the WebSocket protocol can be used to establish a persistent real-time communication session with the proxy server. The proxy server is an intermediary between the user and the session server and the computing server, responsible for request forwarding, load balancing, security control and other functions. Servers may communicate using HTTP or WebSocket+ protocol to achieve efficient data exchange and real-time message delivery.

[0016] Figure 1 The system also includes a Linux server cluster, which includes multiple Linux server nodes numbered Linux1, Linux 2, Linux 3, etc. These Linux server nodes can run different services or applications and provide secure remote access and management capabilities through SSH / SFTP protocols. The session service is responsible for managing user sessions, including authentication, authorization, session persistence, and state synchronization.

[0017] The following combination Figure 1 , the system operation process in the embodiment of the present disclosure is described in detail.

[0018] First, connect to the Linux server through the command line. The specific process of establishing a connection with the remote Linux and interacting with the command line is as follows:

[0019] Step 1101: The user logs into the system through a browser.

[0020] Step 1102: The user enters the target Linux address, username, password or private key in the browser and transmits this information to the session server via http.

[0021] Step 1103: After receiving the information in the previous step, the session server creates an ssh client, then establishes a session connection with the target Linux, and maintains this client connection.

[0022] Step 1104: The user enters the command in the browser, and then uses websocket to pass the command to the client of the session server. The client then passes the command to the target Linux for execution via ssh.

[0023] Step 1105: After executing the command, the Linux server will return the result to the client, which will then pass it to the browser via websocket.

[0024] Step 1106: The user enters the next command in the browser and repeats the process of steps 4 and 5.

[0025] Step 1107: The user sends an instruction to the session server through the browser to end the session, or the user logs out of the system, and the session server terminates the ssh connection with the target Linux and destroys the ssh client.

[0026] Secondly, the user connects to the Linux server through the file system, establishes a connection with the remote Linux and interacts through the file system. The specific process is as follows:

[0027] Step 1201 :Users log in to this system through a browser.

[0028] Step 1202 :The user enters the target Linux address, username, password or private key in the browser and transmits this information to the session server via http.

[0029] Step 1203 : After receiving the information in the previous step, the session server creates an sftp client, then establishes a session connection with the target Linux and maintains this client connection.

[0030] Step 1204 : User reads the target Linux file system.

[0031] Step 1204.1: The user sends a read command via http in the browser to the sftp client of the session server.

[0032] Step 1204.2: The sftp client reads the file system on the target Linux.

[0033] Step 1205 : User creates folder on target Linux.

[0034] Step 1205.1: The user sends a create command to the sftp client of the session server via http in the browser.

[0035] Step 1205.2: The sftp client creates a folder on the target Linux.

[0036] Step 1206 : User renamed the file on the target Linux.

[0037] Step 1206.1: The user sends a rename command via http in the browser to the sftp client of the session server.

[0038] Step 1206.2: The sftp client renames the file on the target Linux.

[0039] Step 1207 : Delete files on the target Linux.

[0040] Step 1207.1: The user sends a delete command via HTTP in the browser to the SFTP client of the session server.

[0041] Step 1207.2: The sftp client deletes the file on the target Linux.

[0042] Step 1208 :User uploads files from local to target Linux.

[0043] Step 1208.1: The user uploads the file from his local computer to the browser.

[0044] Step 1208.2: The browser transfers the file to the sftp client of the session server via http.

[0045] Step 1208.3: The sftp client then transfers the data to the target Linux via sftp, and the session server transmits the upload progress information to the browser via websocket.

[0046] Step 1209 :The user downloads the file from the target Linux to the local computer.

[0047] Step 1209.1: The user sends a download request to the SFTP client of the session server via HTTP in the browser.

[0048] Step 1209.2: The sftp client downloads the file from the target Linux to the sftp client via sftp.

[0049] Step 1209.3: The sftp client passes the file to the http response and returns it to the browser.

[0050] Step 1209.4: The browser saves the received file locally on the user's computer.

[0051] Step 12010 :The user transfers files from target Linux A to target Linux B.

[0052] Step 12010.1: The user sends a command through http in the browser, asking the sftp client A corresponding to Linux A to download the file on Linux A to sftp client A through sftp.

[0053] Step 12010.2: sftp client A transfers the file to sftp client B corresponding to Linux B.

[0054] Step 12010.3: SFTP client B uploads the file to target Linux B via SFTP. Meanwhile, the session server transmits the upload progress information to the browser via WebSocket.

[0055] Step 12011 :The user sends a command to the session server in the browser to end the session, or the user logs out of the system, the session server terminates the sftp connection with the target Linux and destroys the sftp client.

[0056] It should be noted that the above file transfer process is all carried out in memory, and the files do not pass through the session server disk. File transfer can be not only a single file, but also multiple files or folders. At the same time, the transfer progress will be fed back to the user on the browser. When connecting to the target Linux in command line mode, this system also provides command prediction function, which is described in detail below.

[0057] According to one or more embodiments, a command input prediction method analyzes and extracts user habits based on user historical commands to predict user input.

[0058] This disclosure defines the terms involved, including the following conceptual terms.

[0059] Pattern:

[0060] In the present disclosure, a pattern refers to a sentence composed of some common words (i.e., command words) existing in multiple commands, and the position order and distance between these common words appearing in each command are the same. Each common word is called a state of the pattern, and multiple pattern states are connected together to form a pattern chain. Those words that are not common are called changing words. If there are changing words, the pattern is called a pattern with changing words. The state of the pattern contains three attributes, the first attribute is the state value, which is equal to the corresponding common words. The second attribute is the state sequence number, which records the sequential position of the state in the pattern chain. The third is the state distance, which records the distance between the current state and the previous state, that is, how many words are there between two adjacent states. Each state in the pattern chain is called the parent state of the adjacent state thereafter, and the state can also be called a node. For example, there are several commands in Table 1 below.

[0061] Table 1

[0062] command npminstall babel-cli–-save-dev npminstall webpack–-save-dev npminstall style-loader–-save-dev npminstall autoprefixer–-save-dev

[0063] They all have the following structure, where * represents a word that has an uncertain change in this position. npminstall*--save-dev

[0064] The above is a pattern. Each word in the pattern is called a state of the pattern. The state contains both the value and its position in the pattern, as well as the distance between the current state and the previous state. For example, the above pattern has three states, which can be recorded in Table 2 as follows:

[0065] Table 2

[0066] State State number (state_number) The distance from the previous state (distance) npm 1 0 install 2 1 --save-dev 3 2

[0067] These three states constitute a pattern chain, each state is called a node of the pattern chain, and the previous node is called the parent node of the next node.

[0068] If the changed word appears at the end, the last state is recorded as empty, for example, the pattern npminstall* can be recorded as Table 3;

[0069] Table 3

[0070] State State number (state_number) The distance from the previous state (distance) npm 1 0 install 2 1 3 1

[0071] Dialogue:

[0072] Refers to a series of sentences with a front-to-back relationship consisting of some common commands or commands that satisfy common patterns in multiple groups of commands, and the order and distance between these common commands or common patterns in each group of commands are the same. Each common command or common pattern is called a state of the dialogue, and multiple dialogue states connected together form a dialogue chain. The state of the dialogue contains four attributes. The first attribute is the state type, which has two types: satisfying a certain pattern and not satisfying any pattern. The second attribute is the state value. If the state type satisfies a certain pattern, the state value is the pattern that is satisfied, otherwise it is a common command. The third attribute is the state sequence number, which records the sequential position of the state in the dialogue chain. The fourth is the state distance, which records the distance between the current state and the previous state, that is, how many commands are there between two adjacent states. Each state in the dialogue chain is called the parent state of the adjacent state, and the state can also be called a node. For example, the commands in Table 4 below:

[0073] Table 4

[0074] order command 1 pwd 2 node-v 3 npm view babel-cli 4 npminstall babel-cli–-save-dev 5 whoami 6 pwd 7 ls 8 npm view webpack 9 npminstall webpack–-save-dev 10 cd project 11 mvn clean install 12 cd.. 13 pwd 14 date 15 npm view style-loader 16 npminstall style-loader–-save-dev 17 mkdir test 18 cd test 19 pwd 20 echo "hello" 21 npm view autoprefixer 22 npminstall autoprefixer–-save-dev

[0075] From the above commands, we can see that the following set of commands or patterns appear multiple times, which constitute a dialogue chain, as shown in Table 5:

[0076] Table 5

[0077]

[0078] Each command or mode in a dialogue chain is called a dialogue state.

[0079] Dialogue parameter:

[0080] If at least two states in a dialogue are patterns with changing words, and one of the states is the last state of the dialogue, then if the changing word in the last pattern state is the same as the changing word in the previous pattern state, then the word is called a parameter of the dialogue. For example, in the previous dialogue example, the * in npminstall*--save-dev is a parameter because it is the same as the * in npm view*.

[0081] The present disclosure provides a command input prediction method, which first analyzes the user's historical input and constructs a user habit model. The method includes the following steps:

[0082] A1, split the user's historical input commands;

[0083] A2, generating a mode for the command;

[0084] A3, analyzing the context of the command;

[0085] A4, generating a dialogue according to the command;

[0086] A5, generating dialogue parameters according to the dialogue, so that the command input habit model includes the command mode, dialogue and dialogue parameters.

[0087] A1, Split command.

[0088] All user input commands are saved in a command table in chronological order. For example, Table 6 below. The meaning of each column in the table is as follows:

[0089] id: the unique id of the record;

[0090] user_id: which user the command corresponds to;

[0091] content: the content of the command;

[0092] pattern_id: the id of the pattern that the command satisfies;

[0093] create_time: the time when the command was entered;

[0094] Table 6 (command):

[0095] id user_id content pattern_id create_time 1 1 pwd 1603831925868 2 2 ls 1603831940868 3 2 cd / opt / project / config 1603831941868 4 1 ls 1603831925968 5 1 npm view webpack 1603831926068 6 1 npm install webpack --save-dev 1603831926168 7 2 mkdir cert 1603831942868 8 2 cd cert 1603831943868

[0096] Each command of the user will be split and saved in a state_transition table. The splitting method is as follows: the first word of the command and each word except the first word are combined together, and the distance between the two words in the command is recorded. In natural language processing, any two words in each sentence are often recorded, and then the number of times they appear in all the split results is counted to determine whether the pair of words is enough to form a pattern. In this way, a command with n words will have n(n-1) / 2 combinations. The present disclosure is also based on a similar idea, but the difference is that the present disclosure uses a basic fact in the computer field, that is, the first word of all commands has a fixed keyword. If a command has a pattern, the first node of the pattern must be the keyword. For example, all java commands start with java, such as java-version, java-Ddb_name=a-jar test1.jar. All npm commands start with npm, such as npminstall test1--save-dev. If there is a pattern here, the pattern must start with java or npm. For example, java-jar, npminstall. By taking advantage of this, we only need to record the first word of the command and the combination of other words besides the first word. In this way, for a command with n words, we only need to record n-1 records. This is only 2 / n of the original, which greatly reduces the amount of data and ensures that all information is not lost. For a command containing n words, there will be n-1 records. For example, the command "npminstall webpack--save-dev" will be split into the following 3 records:

[0097] Table 7state_transition:

[0098] user_id command_id first_state second_state distance 1 6 npm Install 1 1 6 npm webpack 2 1 6 npm --save-dev 3

[0099] If the command contains only one word, the word is recorded as first_state, second_state is set to a null value, and distance is recorded as 0. For example, the command "ls" is recorded in the state_transition table as follows:

[0100] Table 8 state_transition:

[0101] user_id command_id first_state second_state distance 1 4 ls 0

[0102] A2, Generate a pattern. Based on the generated state_transition data, generate a pattern as follows:

[0103] S201, search for records with distance < 2 in state_transition;

[0104] S202, group by first_state;

[0105] S203, calculating each group to determine whether the number of group records is greater than a certain threshold T;

[0106] S204, if grouped by second_state and distance, record:

[0107] parent_id = id of parent pattern;

[0108] state = the group second_state;

[0109] state_number=parent state_number+1;

[0110] distance=distance-absolute_distance of the group;

[0111] absolute_distance = the distance of this group;

[0112] If not grouped by second_state and distance, then:

[0113] parent_id=(null);

[0114] state = the group's first_state;

[0115] state_number = 1;

[0116] distance=0;

[0117] absolute_distance=0;

[0118] S205, check whether there is a record in the pattern table that has the same parent_id, state, state_number, and distance as in the previous step. If not, insert such a pattern record;

[0119] S206, insert a record with the following structure into the pattern_stat table:

[0120] {

[0121] id:1

[0122] user_id:1,(current user's id)

[0123] pattern_id:1, (the id of the pattern in the previous step)

[0124] happened_times:3857

[0125] likely_grade:9134.893793

[0126] }

[0127] Among them, happened_times records the number of commands that meet the pattern.

[0128] S207, search for all commands that satisfy the pattern in step S205, and search for all state_transition records belonging to these commands with distance = absolute_distance + 1; determine whether there are records with a number greater than a certain threshold T;

[0129] S208, search the pattern table for a record where state is empty, distance is 1, state_number is equal to state_number+1 of the pattern in step S205, and parent_id is equal to the id of the pattern in step S205. If not, insert such a pattern record.

[0130] S209, insert a record with the following structure into the pattern_stat table:

[0131]

[0132]

[0133] Among them, happened_times records the number of commands that meet the pattern of the previous step.

[0134] S210, search for all commands that satisfy the pattern in step S205 and state_transition records with distance>absolute_distance, group them by second_state and distance, and use the pattern in step S205 as the parent pattern for the next step of calculation.

[0135] The likely_grade in step S206 is the score of the user corresponding to the current pattern, which represents the likelihood of the pattern. The calculation method is as follows:

[0136] First, sort the records in the command table in descending order by time and number each row with a positive integer starting from 1, with the first row numbered 1, the second row numbered 2, and so on. Then find all commands that satisfy the current pattern. Calculate the average row_average and standard deviation std of these command numbers. Let total_command be the total number of commands, so likely_grade can be calculated as follows:

[0137] likely_grade=state_number*std*total_command / row_average

[0138] state_number represents the length of the current pattern;

[0139] std represents the dispersion or time span of commands that satisfy the current pattern. A larger value indicates a larger span.

[0140] row_average represents how close the current pattern is to the current time; the closer it is, the closer it is to the user's current working input habits.

[0141] Figure 2 The process discloses a pattern recognition subsystem based on state transition analysis. The system first filters out records with a specific distance value in the state transition. The filtered records are grouped according to the first state, and the number of records in each group is calculated. If the number of records is greater than a certain threshold T, the calculation continues, otherwise the calculation starts for the next group of records. According to different grouping methods, the parent pattern ID, state, state sequence number, distance, absolute distance and other information are recorded.

[0142] In the pattern table (pattern), search for records that match the parent ID, state, state sequence number, and distance calculated in the previous step. If there is no matching record, insert a new pattern record. Insert a record in the pattern statistics table (pattern_stat), including the user ID, pattern ID, number of occurrences (happened_times), and likelihood score (likely_grade). Find all commands that meet the matching pattern conditions, and find all state transition records belonging to these commands and whose distance is equal to the absolute distance plus 1. If the number of records is greater than a certain threshold, continue the subsequent calculation, otherwise start the calculation for the next group.

[0143] Check whether there is a record in the pattern table with empty state, distance 1, state number equal to the state number of the matching pattern plus 1, and parent ID equal to the record ID of the matching pattern. If not, insert a new pattern record. Insert a record in the pattern statistics table, including user ID, pattern ID, number of occurrences, and probability score. Find all commands that meet the matching pattern conditions and state transition records with a distance greater than the absolute distance, and group them by the second state (second_state) and distance, and use the matching pattern as the parent pattern for the next step of calculation.

[0144] By process Figure 2 The process continues until no new pattern is found, and eventually a pattern tree is obtained, from the first pattern node to the leaf nodes of each branch. For example, as shown in Table 9:

[0145] Table 9 pattern:

[0146] id parent_id state distance state_number 1 npm 0 1 2 1 1 2 3 1 install 1 2 4 3 1 3 5 3 --save-dev 2 3

[0147] The obtained pattern_stat data is similar to the following Table 10:

[0148] Table 10 pattern_stat:

[0149] id user_id pattern_id happened_times likely_grade 1 1 1 3857 9134.893793 2 1 2 2091 7355.087892 3 1 3 1762 14983.987003 4 1 4 1355 6403.2778313 5 1 5 843 9609.8975834

[0150] Suppose there are c commands, and the length of each command (i.e. the number of words) is n. Then the number of combinations of each command that contains the first word is 2. n-1 ,c commands total c×2 n-1 Suppose that the same combination appears at least T times to form a pattern, and that there are k different patterns in c commands, and each pattern has k i The same combination appears, among which k i ≥T(i=1,2,…k). Then we have the following equation:

[0151]

[0152] R is the number of all combinations that do not form a pattern.

[0153] The maximum value of k is further obtained:

[0154]

[0155] It can be seen that the more commands there are and the longer the command length is, the more patterns there are. On the contrary, the larger the threshold T is, the smaller the number of patterns is. However, in practice, the number of patterns is far less than the maximum value it can take.

[0156] For a command, it may satisfy multiple patterns at the same time. In this case, the pattern with the largest likely_grade of the corresponding pattern_stat is selected as the pattern that the command satisfies. The corresponding pattern ID is counted in the pattern_id column of the command table. For example, as shown in Table 11:

[0157] Table 11command:

[0158] id user_id content pattern_id create_time 1 1 pwd 1603831925868 2 2 ls 1603831940868 3 2 cd / opt / project / config 320 1603831941868 4 1 ls 1603831925968 5 1 npm view webpack 94 1603831926068 6 1 npm install webpack --save-dev 5 1603831926168 7 2 mkdir cert 487 1603831942868 8 2 cd cert 320 1603831943868

[0159] A3, analyze the correlation between commands, such as Figure 3 shown.

[0160] According to the obtained new command data with mode information, the before and after correlation of the command is analyzed and processed: S301, the following calculation is performed for each command of the user;

[0161] S302, record the current command as first_command, and insert a record with the following structure into the pattern_transition table:

[0162] {

[0163] id:1

[0164] user_id:1,(current user's id)

[0165] start_command_id:1, (the id of the current command)

[0166] parent_id:(empty)

[0167] state_pattern: true, (the current first_command is true if it satisfies a certain pattern, otherwise it is false)

[0168] state:803, (if state_pattern is true, take the corresponding pattern id, otherwise take the current first_command content)

[0169] distance:0

[0170] };

[0171] S303, for each of the n commands following the current first_command command, perform the following calculation;

[0172] S304, record the current command as second_command, and insert a record with the following structure into the pattern_transition table:

[0173] {

[0174] id:2

[0175] user_id:1,(current user's id)

[0176] start_command_id: 1, (equal to the start_command_id in step 2)

[0177] parent_id:1,(id of the record created in step 2)

[0178] state_pattern:false, (the current second_command is true if it satisfies a certain pattern, otherwise it is false)

[0179] state: "pwd", (if state_pattern is true, take the id of the corresponding pattern, otherwise take the content of the current second_command)

[0180] distance:3,(the distance from second_command to first_command)

[0181] }.

[0182] Figure 3A pattern transition record subsystem based on user command analysis is disclosed. The system performs initialization calculation for each command (command) issued by the user and inserts a record in the pattern transition table (pattern_transition). This record contains pattern transition ID, user ID, starting command ID, parent pattern transition ID (initially empty), state pattern mark (state_pattern), state (state), and distance (distance). The current command is recorded as the first command (first_command). If the first command (first_command) conforms to a certain pattern (pattern), the state pattern mark is true, and the ID of the corresponding pattern is taken as the state; if it does not conform, the state pattern mark is false, and the content of the first command is used as the state. Each of the n subsequent commands after the first command is calculated, and the current subsequent command is recorded as the second command (second_command). A pattern transition record is inserted in the pattern transition table pattern_transition. This record contains pattern transition ID, user ID, starting command ID whose value is the first command ID, pattern transition parent ID, state pattern mark, state, and distance. For each subsequent command, if the current second command conforms to a certain pattern, the status pattern is marked as true, and the ID of the corresponding pattern is taken as the state; if it does not conform, the status pattern is marked as false, and the content of the current second command is taken as the state; the distance is the distance between the second command and the first command, and the parent ID is the ID of the previously inserted mode conversion record.

[0183] By process Figure 3 After analyzing all the commands, you will get data similar to the following Table 12:

[0184] Table 12 pattern_transition:

[0185] id user_id start_command_id parent_id state state_pattern distance 1 1 1 pwd false 0 2 1 1 1 ls false 1 3 1 1 1 94 true 2 4 1 1 1 1547 true 3

[0186] A4 generates a dialogue. Based on the obtained pattern_transition data, follow the process Figure 4 To generate a dialogue:

[0187] S401, search for records in which parent_id is empty in pattern_transition;

[0188] S402, group by state, state_pattern;

[0189] S403, performing calculations on each group to determine whether the number of group records is greater than a certain threshold T;

[0190] S404, if grouped by state, state_pattern and distance, then record:

[0191] parent_id = id of parent dialogue;

[0192] state = the group state;

[0193] state_pattern=this set of state_pattern;

[0194] state_number=parent state_number+1;

[0195] distance=distance-absolute_distance of the group;

[0196] absolute_distance = the distance of this group;

[0197] If not grouped by state, state_pattern and distance, then:

[0198] parent_id=(null);

[0199] state = the group state;

[0200] state_pattern=this set of state_pattern;

[0201] state_number = 1;

[0202] distance=0;

[0203] absolute_distance=0;

[0204] Remember start_command_ids = all start_command_ids of this group of pattern_transition;

[0205] S405, check whether there is a record in the dialogue table that has the same parent_id, state, state_pattern, state_number, and distance as in the previous step. If not, insert such a dialogue record; S406, insert a record with a structure similar to the following into the dialogue_stat table:

[0206] {

[0207] id:1

[0208] user_id:1,(current user's id)

[0209] dialogue_id:1,(the id of the previous dialogue)

[0210] happened_times:743

[0211] likely_grade:2548.6542908

[0212] }

[0213] Among them, happened_times records the number of commands that satisfy the dialogue.

[0214] S407, search for all pattern_transition records that satisfy the start_command_id in the start_command_ids of step S404 and whose distance>absolute_distance, and group them by state, state_pattern and distance. Take the dialogue of step S405 as the parent dialogue for the next calculation.

[0215] Among them, the likely_grade in step S406 is the score of the user corresponding to the current dialogue, which represents the likelihood of the dialogue. Its calculation method is as follows:

[0216] First, sort the records in the command table in descending order by time and number each row with a positive integer starting from 1, with the first row numbered 1, the second row numbered 2, and so on. Then find all commands whose ids are in start_command_ids. Calculate the average row_average and standard deviation std of these command numbers. Let total_command be the total number of commands, so likely_grade can be calculated as follows: likely_grade = state_number*std*total_command / row_average

[0217] state_number represents the length of the current dialogue;

[0218] std represents the dispersion or time span of commands that satisfy the current dialogue. A larger value indicates a larger span.

[0219] row_average represents how close the current dialogue is to the current time; the closer it is, the closer it is to the user's current working input habits.

[0220] Figure 4 The flowchart discloses a subsystem based on dialogue recognition and recording. First, find the records with empty parent_id in the pattern transition table (pattern_transition), group them by state (state) and state pattern (state_pattern), and calculate each group of records.

[0221] If the number of records in the current group is greater than a certain threshold, the subsequent calculation continues; otherwise, the calculation of the next group begins.

[0222] According to different grouping methods, the parent conversation ID (parent_id), state (state), state mode (state_pattern), state number (state_number), distance (distance), absolute distance (absolute_distance) and all start command ID lists (start_command_ids) of the current group are recorded.

[0223] Search the dialogue table for a record that has the same parent_id, state, state_pattern, state_number, and distance as the previous step. If there is no such record, insert one.

[0224] Insert a record into the dialogue statistics table (dialogue_stat), including the user ID (user_id), dialogue ID (dialogue_id), number of occurrences (happened_times), and likelihood score (likely_grade).

[0225] In the pattern transition table (pattern_transition), search for all pattern transition records whose start command ID is in the aforementioned start_command_ids and whose distance is greater than the absolute distance. Group the search results by state, state pattern, and distance, and use the current matching dialogue as the parent dialogue for the next step of calculation.

[0226] By process Figure 4 The process continues until no new dialogue is found, and eventually a dialogue tree is obtained, from the first dialogue node to the leaf nodes of each branch. For example, as shown in Table 13:

[0227] Table 13dialogue:

[0228] id parent_id state state_pattern distance state_number 1 pwd false 0 1 7 1 94 true 2 2 59 7 1547 true 1 3

[0229] At the same time, the records of dialogue_stat are obtained, such as the following table 14:

[0230] Table 14dialogue_stat:

[0231] id user_id dialogue_id happened_times likely_grade 1 1 1 223 35765.98314 2 1 7 28 19241.09543 3 1 59 28 28672.21762

[0232] Suppose there are c commands, and each group of n adjacent commands is used as the statistical length of the dialogue. Then the number of combinations of all commands including the first command in each group is 2. n-1 ,c commands are close to c×2 n-1 Suppose the same combination appears at least T times to form a dialogue, and suppose there are k different dialogues in c commands, and each dialogue has k i The same combination appears, among which k i ≥T(i=1,2,…k). Then we have the following equation:

[0233]

[0234] R is the number of all combinations that do not form a dialogue.

[0235] The maximum value of k is further obtained:

[0236]

[0237] It can be seen that the more commands there are, the longer the group length is, and the more dialogues there are. On the contrary, the larger the threshold T is, the smaller the number of dialogues is. However, in practice, the number of dialogues is far less than the maximum value it can take.

[0238] A5, generate dialogue parameters.

[0239] For each dialogue, if the last node of the dialogue chain is a pattern with a changed word, then the changed word information between the last node and all the nodes with a changed word pattern before the last node in the dialogue is counted. The counting method is as follows:

[0240] Find all commands that satisfy the dialogue. Then, based on these commands, count each changed word in the last pattern node of the dialogue and all patterns with the same changed word before the last node. Count their positions. When the number of combinations of the same positions is greater than a certain threshold T, the changed word in the position combination is considered to constitute a parameter of the dialogue.

[0241] For example, for the following dialogue with id equal to 59:

[0242] pwd

[0243] npm view*

[0244] npm install * –save-dev

[0245] Where * represents the parameters of the dialogue.

[0246] According to the process Figure 5 The process steps in the above example generate dialog parameters. The process includes the following steps:

[0247] S501, for the last node in the dialogue chain, determine whether it is a pattern with a changed word, if so, continue with the subsequent calculation, if not, do not perform the subsequent calculation;

[0248] S502, performing subsequent calculations on each changed word of the last node in the dialogue chain;

[0249] S503, record the current changed word position in the previous step as first_state_location, calculate each node before the last node in the dialogue chain to determine whether it is a pattern with a changed word, if so, perform subsequent calculations, if not, start calculating the next node;

[0250] S504, record the current dialogue node position in the previous step as second_pattern_location, and perform subsequent calculations on each changed word of the node;

[0251] S505, record the current change word position in the previous step as second_state_location. In all command groups that satisfy the current dialogue, count the number of command groups whose state at the change word position of first_state_location is the same as the state at the change word position of second_pattern_location node second_state_location, and determine whether the number of groups is greater than a certain threshold T. If so, continue the subsequent calculation, if not, start the calculation for the next node;

[0252] S506, check whether there is a record in the dialogue_parameter table that is equal to the id of the current dialogue and the first_state_location, second_pattern_location, and second_state_location of the previous step. If not, insert such a dialogue_parameter record;

[0253] S507, insert a record with the following structure into the dialogue_parameter_stat table:

[0254] {

[0255] id:1

[0256] user_id:1,(current user's id)

[0257] dialogue_parameter_id:1,(the id of the dialogue_parameter in the previous step)

[0258] happened_times:49

[0259] }

[0260] Among them, happened_times records the number of commands that meet the dialogue_parameter.

[0261] Figure 5 The flowchart discloses a pattern recognition and parameter recording subsystem based on the dialogue chain. The system first identifies whether the last node in the dialogue chain is a pattern with a changed word. If so, it continues the subsequent calculation and records the position of the current changed word as first_state_location.

[0262] Then, we calculate each node before the last node of the conversation chain. If the current node is a pattern with a changed word, we continue to calculate. Otherwise, we start to calculate the next node. We record the location of the current node as second_pattern_location, and calculate each changed word of the current node.

[0263] The position of the current changing word is recorded as second_state_location. In all command groups that satisfy the current dialogue, the number of command groups whose state at first_state_location is the same as the state at second_pattern_location node second_state_location is counted. If the number of command groups is greater than a certain threshold, continue to calculate, otherwise start to calculate the next changing word.

[0264] Check the dialogue_parameter table to see if there is a record with the same id, first_state_location, second_pattern_location, and second_state_location as the current dialogue. If not, insert such a dialogue_parameter record.

[0265] Insert a record into the dialogue parameter statistics table dialogue_parameter_stat. The record includes ID, user ID, dialogue parameter ID and occurrence count.

[0266] By process Figure 5 The dialogue_parameter data can be obtained, for example, as shown in Table 15 below:

[0267] Table 15dialogue_parameter:

[0268]

[0269]

[0270] At the same time, the corresponding dialogue_parameter_stat data is obtained, such as the following Table 16:

[0271] Table 16dialogue_parameter_stat:

[0272] id user_id dialogue_parameter_id happened_times 1 1 1 16 2 1 2 31

[0273] Suppose there are c commands, and each group of n adjacent commands is used as the statistical length of the dialogue. Then the number of combinations of all commands including the first command in each group is 2. n-1 ,c commands are close to c×2 n-1 Suppose the same combination appears at least T times to form a dialogue, and there are k different dialogues in c commands, and each dialogue has p i The same combination appears, among which k i ≥T(i=1,2,…k). Let a be the maximum number of parameters of the pattern in the dialogue. According to the equation of the previous dialogue, we have the following result:

[0274]

[0275] R is the number of all combinations that do not form a dialogue.

[0276] For combinations that satisfy the length of the dialogue n, all possible parameter combinations are much smaller than na 2 ×k i The total number of parameters is less than na 2 (c×2 n-1 ). In practice, the number of parameters is much smaller than this value. Because in order to become a parameter, first there must be a pattern with a parameter in the dialogue, and then the parameters of the corresponding pattern must be equal, resulting in a small number of parameters.

[0277] The present disclosure provides a command input prediction method, which predicts user input by using a constructed command input habit model.

[0278] The system will periodically calculate and generate patterns, dialogues, and dialogue parameters that match the user's habits based on each user's commands in the aforementioned steps.

[0279] After the user uses ssh to connect to the remote target Linux machine, the pattern, dialogue and dialogue parameters will be matched according to the user's input history and the current input part in the command line, and the command that the user may enter next will be predicted according to the probability.

[0280] For example, when the user enters the letter n when entering the first command, the system will search for all patterns that begin with n and sort them by their likelihood. The following results may be returned:

[0281] npm install

[0282] npm viewnode -v

[0283] npm audit

[0284] ng add

[0285] If the user then enters npm, the system will further narrow the matching range to all patterns starting with npm:

[0286] npminstall

[0287] npm view

[0288] npm audit

[0289] If the user enters npm v, the system matches npm view. The user can select npm view and continue to enter the following.

[0290] Assume that the complete command entered by the user is npm view react. The system will look for the most likely pattern to match the command. If it is found, the command will be marked as matching the largest pattern. If not, the command will be marked as not matching any pattern.

[0291] When the user executes the current complete command and starts to enter the next command, the system will search for all matching dialogues based on the command just entered, and return the commands that the user may enter next in order of probability, for example:

[0292] npminstall

[0293] npm update

[0294] ng add

[0295] At the same time, the system will check whether all matching dialogues have parameters. If there are parameters, they will be returned together with the parameters. The final result is as follows:

[0296] npm install react –-save-dev

[0297] npm update

[0298] ng add react

[0299] At this time, the user can choose whether the predicted results contain the command they expect. If not or if they want to narrow the scope, they can enter further commands. For example, if the user enters np, the system will predict the dialogue, dialogue parameters and pattern that the user matches based on the user's historical commands and the newly entered partial commands, and finally return a prediction result similar to the following:

[0300] npm install react –-save-dev

[0301] npm update

[0302] After the user completes entering a new command, the system searches for the pattern that is most likely to match the new command. If it is found, the command is marked as matching the maximum pattern. If it is not found, the command is marked as not matching any pattern. When the user starts to execute a new command and is about to enter the next command, the system will also match the dialogue, dialogue parameters, etc. based on the historical commands. This process continues.

[0303] The command input prediction system disclosed in the present invention calculates two sets of patterns, dialogue and dialogue_parameter. One set is global and the other is local. The global one is calculated based on all the historical input commands of the user. The local one is calculated based on the most recent command input by the user. The global one represents the overall command usage habits of the user. The local one is closely related to the work that the user is currently focusing on. The system puts the results of global and local predictions together and arranges them according to the probability to provide them to the user for selection.

[0304] It should be understood that in the embodiments of the present invention, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0305] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0306] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A command input prediction method, characterized in that: According to the user command input history, the user habits are analyzed and extracted, and a user command input habit model is constructed. The user input is predicted by the habit model. The method for constructing the command input habit model includes the following steps: A1, split the user's historical input commands; A2, generating a mode for the command; A3, analyzing the context of the command; A4, generating a dialogue according to the command; A5, generating dialogue parameters according to the dialogue, so that the command input habit model includes the command pattern, dialogue and dialogue parameters.

2. The method according to claim 1, characterized in that: According to the letters that the user has input when inputting the command, according to the command input habit model, according to the matching of the mode, dialogue and / or dialogue parameters, predict and give the command that the user may input next, The mode refers to a command sentence pattern with the same command words in a command set composed of commands; Said same command words are defined as the states of said modes; The dialogue refers to a group of related command sentences with the same command or the same pattern.

3. The method according to claim 2, characterized in that If there are at least two states in a conversation that are patterns with changing command words, and one of the states is the last state of the conversation, then if the changing command word in the last pattern state is the same as the changing command word in a previous pattern state, and the number of identical times exceeds a preset threshold, then the command word is called a parameter of the conversation.

4. The method according to claim 1, characterized in that: Step A1 is to split the user's historical input commands by: Combine the first command word of the command line with other command words in pairs, record the distance between every two command words in the command line, and record them in the state transition table state_transition.

5. The method according to claim 1, characterized in that Step A2 is a method for generating a pattern for the command: First, filter out the records with the specified distance value in the state transition table state_transition; Group the filtered records according to the first status and calculate the number of records in each group; If the number of records is greater than a certain threshold T, continue calculating, otherwise start calculating the next set of records; Record the parent mode ID, state, state sequence number, distance, and absolute distance information according to different grouping methods, and search the mode table for records that match the parent mode ID, state, state sequence number, and distance. If there is no matching record, insert a new mode record. Insert a record into the pattern statistics table, including user ID, pattern ID, number of occurrences, and likelihood score; Find all commands that meet the matching pattern conditions, and find all state transition records belonging to these commands and whose distance is equal to the absolute distance plus 1. If the number of records is greater than a certain threshold T, continue to calculate, otherwise return to the third step of this article to start calculating the next set of records; Check whether there is a record in the pattern table with a state of null, a distance of 1, a state number equal to the state number of the matching pattern plus 1, and a parent pattern ID equal to the ID of the matching pattern. If not, insert a new pattern record; Insert a record into the pattern statistics table, including user ID, pattern ID, number of occurrences, and likelihood score; Find all commands that meet the matching pattern conditions and whose state transition records have a distance greater than the absolute distance, and group them by the second state and distance. Use the matching pattern as the parent pattern and calculate the number of records in each group. Return to step 3 of this article to start calculating each group of records.

6. The method according to claim 1, characterized in that Step A3 analyzes the context relevance of the command, including the following steps: Calculate each command entered by the user, record the current command as the first command, and insert a pattern transition record into the pattern transition table pattern_transition. This record contains the pattern transition ID, user ID, the start command ID whose value is the first command ID, the pattern transition parent ID whose value is empty, the state mode flag, the state, and the distance whose value is 0. If the current first command meets a certain pattern, the status pattern is marked as true, and the ID of the corresponding pattern is taken as the status; if it does not meet the pattern, the status pattern is marked as false, and the content of the current command is used as the status; For each of the n subsequent commands after the first command, calculate and record the current subsequent command as the second command. Insert a pattern transition record in the pattern transition table pattern_transition. The record includes the pattern transition ID, user ID, the start command ID whose value is the first command ID, the pattern transition parent ID, the state mode flag, the state, and the distance. For each subsequent command, if the current second command conforms to a certain pattern, the status pattern is marked as true, and the ID of the corresponding pattern is taken as the state; if it does not conform, the status pattern is marked as false, and the content of the current second command is taken as the state; the distance is the distance between the second command and the first command, and the parent ID is the ID of the previously inserted mode conversion record.

7. The method according to claim 1, characterized in that Step A4 generates a dialogue according to the command, specifically including: First, find the records with empty parent ID in the pattern_transition table, group them by state and state pattern, and calculate each group of records. If the number of records is greater than a certain threshold T, continue calculating, otherwise start calculating the next set of records. According to different grouping methods, record the parent conversation ID, state, state mode, state sequence number, distance, absolute distance and all the starting command ID list information of the current group. Check if there is a record in the conversation table that matches the parent ID, state, state mode, state sequence number, and distance calculated in the previous step. If not, insert a new conversation record. Insert a record into the conversation statistics table, including user ID, conversation ID, number of occurrences, and probability score. Search the pattern transition table for all pattern transition records whose starting command ID is in the current group starting command ID list and whose distance is greater than the absolute distance. Group the search results by state, state pattern and distance. Take the current matching dialogue as the parent dialogue and calculate the number of records in each group.

8. The method according to claim 1, characterized in that Step A5 generates dialogue parameters according to the dialogue, and the specific steps include: First, determine whether the last node of the dialogue chain is a pattern with a changed word. If so, continue the calculation. If not, stop the calculation. Then calculate each changed word of the last node of the dialogue chain, and record the position of the current changed word as the first state position. Calculate each node before the last node in the conversation chain, Determine whether the current previous node is a mode with a changed word. If so, continue calculating. If not, start calculating the next previous node. Remember the current previous dialogue node position as the second mode position, and calculate each changed word of the current previous dialogue node. The current change word position is recorded as the second state position. Among all the command groups that satisfy the current dialogue, the number of command groups whose state at the first state position is the same as the state at the second state position at the second mode position is counted. If the number of command groups is greater than a certain threshold, then check whether there is a record in the dialog parameter table that has the same dialog ID, first state position, second mode position, and second state position as the current dialog. If not, insert such a record. Then insert a record into the conversation parameter statistics table, including user ID, conversation parameter ID, and occurrence count information.

9. A command input prediction system, characterized in that: The system includes a server having a memory; as well as A processor coupled to the memory, the processor being configured to execute instructions stored in the memory to implement the method according to any one of claims 1 to 8.

10. A system based on Web connection to remote Linux / Unix, characterized in that: Including proxy servers, session servers, computing servers and databases, The user establishes an HTTP or WebSocket connection with the proxy server through the browser. The proxy server and the session server are connected using HTTP or WebSocket protocol, and the session server maintains SSH / SFTP connection with multiple Linux or Unix servers. The computing server is connected to the proxy server and the database, and provides command input prediction service for the user when the user inputs a command line.

Citation Information

Cited By

  • Data storage method and device, computer equipment and storage medium

    CN120086221A