Using column values in RegEx
Started by rmpf2
rmpf2
Using column values in RegEx 17 January 2019, 06:02 |
Re: Using column values in RegEx 18 January 2019, 12:41 |
Admin Registered: 18 years ago Posts: 3 519 |
then you could do something like this:
'Return port assignments objTelnet.Send("show mac address-table" & vbCrLf) 'Wait for shell prompt (when command finishes) data = objTelnet.Recv("#") 'Get port column value port = "Gi1/0/" & Input.Column("port") 'Setup a regex object Set objRegex = New RegExp objRegex.IgnoreCase = True objRegex.Multiline = True objRegex.Global = True 'This will capture MAC address from strings like '1 000a.b82d.10e0 DYNAMIC Gi1/0/X objRegex.Pattern = "^\s*\d+\s*([^\s]+)\s*[^\s]+\s*" & port & "$" Set matches = objRegex.Execute(data) For Each match in matches Output.Write match.SubMatches(0) NextThis will extract a complete list of MAC addresses, get a value from the port column and then use that value in the regex to extract MAC addresses bound to the specific port.
rmpf2
Re: Using column values in RegEx 25 January 2019, 09:37 |
Today I did some tests on this. It works but needs some kind of delay before column script execution. After the initial scan the column reflect an error response over the telnet communication. I believe it is because it depends on another column that's on process to show its final value. If I do a post rescan only over that column it shows the result of the show mac address-table as expected.
What do you think? Maybe some kind of wait (sleep-delay) command on top of the script?
Re: Using column values in RegEx 25 January 2019, 09:49 |
Admin Registered: 18 years ago Posts: 3 519 |
You can check whether the port is there by executing the following and see what gets printed:
port = "Gi1/0/" & Input.Column("port") Output.Write port
Also, you mentioned an error. Could you please tell what exactly you are getting?
rmpf2
Re: Using column values in RegEx 25 January 2019, 10:25 |
rmpf2
Re: Using column values in RegEx 25 January 2019, 11:58 |
Re: Using column values in RegEx 25 January 2019, 12:03 |
Admin Registered: 18 years ago Posts: 3 519 |
- The latest builds increase the maximum simultaneous number of dynamic columns of the same type from 10 to 50. The /maxcols switch has been removed. While this should provide more than enough columns for any practical purpose, there is a chance that RegExes and column colours may be lost or assigned to incorrect columns. Unfortunately this has to be fixed manually, but it only needs to be done once and for all. Please make a backup copy of your config files prior to the update.
- If a script depends on other scripts, they need to be placed in a correct order as they are executed from top to bottom, as shown below:
rmpf2
Re: Using column values in RegEx 26 January 2019, 01:41 |
Thanks!!!
Do you think it might be possible to add the following to ease the restore procedure:
- Allow windows to be resized and maximize. Example: Visible columns, Remote scripting, etc... This might allow big amounts of data rows, including visualized regex, to be manipulated (moved or relocated) in an easier and more comfortable way.
- Up and down arrow buttons, maybe move to end, and move to top also (drag and drop is fantastic please don't misunderstand me).
- Format copy (copy regex, text, highlighting and other properties of an specific row to others).
- Alternative to toggle the selected rows. Example: select all, or select only those that are not already selected.
rmpf2
Re: Using column values in RegEx 26 January 2019, 05:47 |
Re: Using column values in RegEx 29 January 2019, 16:20 |
Admin Registered: 18 years ago Posts: 3 519 |
Regarding the issue where the program restores all the hidden columns and erases the regex and properties, could you please provide a reproducible test case? What exactly did you do to make it happen?
In the meantime, good news: we've implemented column layout upgrade from old configuration files. If you download the latest build, it should correctly read all columns details from your configuration files, whether you used /maxcols or not.
rmpf2
Re: Using column values in RegEx 22 February 2019, 04:58 |
Re: Using column values in RegEx 30 July 2019, 04:20 |
Registered: 6 years ago Posts: 15 |
Here's my scenario:
Script "Model" uses "strComputer = Input.Current" and executes a WMI query for the PC Model (("SELECT Model FROM Win32_ComputerSystem"))
The returned string would be something like "OptiPlex 7050" or "Latitude E5450"
This is passed through the Column Display RegEx to strip away extraneous junk.
The final result in the "Model" column would be "7050" or "E5450"
Script "+BIOS" uses "strModel = trim(Input.Column("Model"))" and checks a local path ("C:\DellBIOS\BiosUpdate" & strModel) for a file.
The script ends with "Output.Write(objFSO.GetFileName(objFile))"
This output would be something like "OP7050_1.4.0.exe" or "LE5450_A19.exe"
Again, this is passed through the Column Display RegEx to leave only the version behind.
The final result would be "1.4.0" or "A19".
Script "Model" is the first (top) script in the list, Script "+BIOS" is number 17.
While I was using NetScan version 7.1.9, the +BIOS column would come up blank after the initial scan, but would display after rescanning the column.
After upgrading to version 7.2.3, the +BIOS column does not display at all, even after rescanning.
Re: Using column values in RegEx 30 July 2019, 07:27 |
Admin Registered: 18 years ago Posts: 3 519 |