VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Get specific values from a table (https://forums.vandyke.com/showthread.php?t=13201)

cekoj 08-01-2018 10:22 PM

Get specific values from a table
 
Support me with some problem that i have. We are performed an audit logs but, is there a form to get some specific values in a table?

We have detected 2 different tables as below:
Code:

TABLE 1:
====================================================================================================================================
FRU    LNH    BOARD      ST FAULT OPER MAINT STAT PRODUCTNUMBER  REV    SERIAL        DATE      TEMP
=====================================================================================================================================
BB-1  000100 DUS5301      1  OFF  ON  OFF  ON KDU137848/11    R2B    B441317340    20180407        (Bb6630)

Code:

TABLE 2:
SMN APN  BOARD    FAULT  OPER  MAINT  STAT    PRODUCTNUMBER  REV    SERIAL    DATE    TEMP COREMGR
====================================================================================================================
  0  1  DUW4101  OFF    ON    OFF    OFF    KDU127174/4    R2F    TU8XAW5590 20160726 68C  Active*
--------------------------------------------------------------------------------------------------------------------

The problem is that I want to get PRODUCTNUMBER, REV, SERIAL and DATE. As you see, values are not separate with a constant spaces.

Please, if you can give me an advice or support, provide your feedback.

bgagnon 08-02-2018 07:47 AM

Hi cekoj,

What version of SecureCRT are you using?

On what OS/platform?

Please review the scripting manual here.

In Chapter 4, it contains info on Reading Data from Remote Machines.

cekoj 08-06-2018 10:04 AM

This is Version 7.0.4 (x64 build 537)

Actually i tried using the manual but i'm still with problems because only i got one value and the others are not working. I'd like to know how you structure your scripts for this kind of request

bgagnon 08-06-2018 11:29 AM

Hi cekoj,

That's a really old version of SecureCRT.

Please elaborate on what you mean by "only got one value".

Since there is an inconsistent amount of spaces *separating* the data you wish to get, you will have to look for other ways to isolate what you need.

Is there a consistent number of characters (and spaces) for all four fields taken together? (In other words, could you get 50 characters in the line each time and then split it on the spaces and trim the results?)

If not, is there a pattern to each field so you can isolate each one? (Is there always a "/" in Product Number? Is "R2" always found in Rev? Is the Serial a consistent number of alphanumeric characters? Is the Date consistently YYYYMMDD?)

bstedh 08-14-2018 11:43 AM

Remove all the excess spaces and then split by space to put each item in an array.

Start by reading the line into a variable.
Code:

input = crt.Screen.Readstring (vbCr)
Remove excess spaces

Code:

Do While InStr(1,input,"  ") 'loop while there are more than just single spaces
    input = Replace(input,"  "," ") 'replaces double spaces with a single space
Loop

Split the input into an array that contains each item in the line.

Code:

arroutput = Split (input," ") 'splits the info using a space as a delimiter
Now the array arroutput contains each item separately to use as you would like.

cekoj 08-29-2018 10:35 PM

Thanks for your analysis. I got to add in my script in order to read all sites and configure properly.


All times are GMT -6. The time now is 12:52 AM.