TN - 1225 Searching for Script - Strings in a Galaxy
Description
This article from InSource shows a couple mechanisms available for locating scripts - strings within a Galaxy.
- Author: Mario Meza
- Published: 03/10/2022
- Applies to: Application Server and InTouch OMI
Details
You may find you need to search for references in scripts within your galaxy. For example Galaxy references used in OMI are not supported and can cause issues.
The following two options may be of value in locating string / scripts depending on where they are defined.
Note the options outlined in this document are not officially supported by AVEVA. Always execute caution when running any script or utility in a production environment.
Option 1:
- A utility known as the GRScript search utility which is actually not a Utility as you might imagine. It’s actually a SQL script written by a technical support engineer as a useful tool and is not an official tool AVEVA supports. There is no documentation associated with the product. In theory the tool should work with all versions however it will not have gone through extensive testing.
- To use it just remove the .txt from the filename and open from SSMS or copy and paste the text in a query.
- A copy of the utility can be accessed from the following link.
In testing a script was updated in a test object called hudClar1Flow. A unique comment was added saved and checked it in.
'Needle.In.Haystack can you find this? d[-!-]b
'Galaxy:"Object.attribute"
In SQL Server Management Studio the GRScript search Query was opened and the Database / Galaxy Name to use was updated. For this example the name of the Galaxy is (test).
The second thing to update is the string to search for. For this example we use (‘Haystack’).
As you can see in the result set it returns the relevant object information so you can take that information and can go to the Galaxy and locate or 'find' any Object(s) and Script(s) containing that string.
Option 2:
- Use a deep search utility to search object exports. This can be layouts, OMI apps, objects or any combination.
While the GRScript search utility is terrific at what it does, it does not search in any scripts contained / defined in OMI (for example layout scripts).
This is where using a deep search utilty like Agent Ransack, File locator Pro, File seek can come in handy.
For this test a script comment was added to a layout called Root Layout in a Galaxy called OMI_USA_DEMO.
The object was saved and checked it in.
'YetAnother Haystack.Needle d[-!-]b
OMI Apps which contain Layouts were then exported
The OMI app .aapkg was extracted with 7-zip (you can also update the extension to .zip manually and extract)
In the containing folder of an .aapkg is a File1.cab. Again extract with 7-zip (you can also update the extension to .zip manually and extract)
For this test FileLocator was used, which is the updated version of Agent Ransack.
To use simply specify the following:
- The folder to search in the 'Look in:' field (This is the file path to the extracted File1.cab)
- The search term in the 'Containint text:' field (haystack)
As you can see we get a hit. Scripts are contained in numbered .txt files, you can right click the .txt file and select how you would like to open it.
For these tests the .txt file was opened in notepad. As you can see of the text that is not obfuscated you can pick out where this script is located. Remember the comment was defined in a layout called RootLayout and we searched an OMI applications export from a Galaxy called OMI_USA_DEMO.
Following the same procedure the same information can be gleaned from an export of all the layouts
Final things to be aware of :
- The text layout of a script .txt file is not always the same. So you may need to dig a bit at first but it’s rather straight forward once you get the hang of it.
- Some string in a script .txt file may have spaces in them so if you dont get a hit searching for a particular 'term' try searching for a paticular 't e r m'
- This technique does not work on a .CAB export of a galaxy.