Script search
Search a text or a regular expression in the MQL code of all the scripts of the server and get one row per matching line with the script name, the line, the column and an excerpt. A user sees only the scripts he may read with script get, and the search is bounded in results and in time. Typical uses: find every script that calls a function or a connection before changing it, the Search in all scripts window of the MentDB editor.
script search <pattern>
Description
Search a text in the code of the scripts the user can read, case insensitive: {pattern, regex, scripts (the scripts the user can read), scripts_searched, scripts_matched, matches (matching lines), returned, truncated, timed_out, skipped_lines, rows: [{script, line, column, excerpt}]} sorted by script name then line
Search a text in the code of the scripts the user can read, case insensitive: {pattern, regex, scripts (the scripts the user can read), scripts_searched, scripts_matched, matches (matching lines), returned, truncated, timed_out, skipped_lines, rows: [{script, line, column, excerpt}]} sorted by script name then line
Parameters
pattern: The text to find (or a Java regular expression with regex true), searched in each line of the code - String - required
pattern: The text to find (or a Java regular expression with regex true), searched in each line of the code - String - required
admin
script search "hello"
mentdb
{"pattern": "hello", "regex": false, "scripts": 2, "scripts_searched": 2, "scripts_matched": 2, "matches": 2, "returned": 2, "truncated": false, "timed_out": false, "skipped_lines": 0, "rows": [{"script": "a.exe", "line": 2, "column": 12, "excerpt": "log write \"Hello World\";"}, {"script": "b.post", "line": 2, "column": 1, "excerpt": "hello again hello"}]}
script search <pattern> <json_params>
Description
Search with parameters: regex (false: the pattern is a plain text), case_sensitive (false), whole_word (false: true needs no letter of any alphabet, accented letters included, no digit and no _ just before and after the match), prefix (only the scripts whose name starts with it, case insensitive), max_results (500, 1 to 10000), max_per_script (100), excerpt_max (200 characters, 20 to 2000: a longer line is cut around the match), timeout_ms (10000, 100 to 60000)
Search with parameters: regex (false: the pattern is a plain text), case_sensitive (false), whole_word (false: true needs no letter of any alphabet, accented letters included, no digit and no _ just before and after the match), prefix (only the scripts whose name starts with it, case insensitive), max_results (500, 1 to 10000), max_per_script (100), excerpt_max (200 characters, 20 to 2000: a longer line is cut around the match), timeout_ms (10000, 100 to 60000)
Parameters
pattern: The text to find (or a Java regular expression with regex true), searched in each line of the code - String - required
json_params: The parameters - String - required
pattern: The text to find (or a Java regular expression with regex true), searched in each line of the code - String - required
json_params: The parameters - String - required
admin
script search "^\s*error\b" "{\"regex\": true}"
mentdb
{"pattern": "^\\s*error\\b", "regex": true, "scripts": 2, "scripts_searched": 2, "scripts_matched": 1, "matches": 1, "returned": 1, "truncated": false, "timed_out": false, "skipped_lines": 0, "rows": [{"script": "a.exe", "line": 4, "column": 1, "excerpt": "ERROR here"}]}
Fixed result on a server with the scripts a.exe and b.post (a session is needed): only the scripts whose name starts with a., case sensitive
admin
script search "Hello" "{\"case_sensitive\": true, \"prefix\": \"a.\"}"
mentdb
{"pattern": "Hello", "regex": false, "scripts": 2, "scripts_searched": 1, "scripts_matched": 1, "matches": 1, "returned": 1, "truncated": false, "timed_out": false, "skipped_lines": 0, "rows": [{"script": "a.exe", "line": 2, "column": 12, "excerpt": "log write \"Hello World\";"}]}
A regular expression that is not valid
admin
script search "(" "{\"regex\": true}"
mentdb
ERROR: Sorry, an error appears (the parameter 'pattern' is not a valid regular expression (Unclosed group near index 1)).
