Return text from a text file

(imported topic written by JesseR91)

lets say I have a text file, (c:\text.txt) that has the following information in it:

Small Numbers

1

2

3

4

5

6

7

8

9

10

Big Numbers

1000

1001

1002

1003

How can I retrieve the values following ‘Big Numbers’ ?

I have been wrecking my brain on this. I can do it fine if I specify my own string but pulling from a file I cannot.

(imported comment written by BenKus)

Hey JesseR,

Here are a few tricks:

q: (substrings separated by “;;;;” of following texts of first “Big Numbers” of concatenation “;;;;” of lines of file “test.txt” of folder “C:\Users\ben_kus\Desktop”)
A:
A: 1000
A: 1001
A: 1002
A: 1003
T: 0.591 ms
I: plural substring

OR (more difficult syntax)

q: items 0 of (lines of file “C:\Users\ben_kus\Desktop\test.txt” ,it) whose (line number of item 0 of it > item 1 of it) of it of ((line number of line whose (it as lowercase = “big numbers”) of file “C:\Users\ben_kus\Desktop\test.txt” ))
A: 1000
A: 1001
A: 1002
A: 1003
T: 0.564 ms
I: plural file line

Ben

(imported comment written by JesseR91)

Thanks Ben. I am working on getting a better grip on following text and preceding text functions. What if I wanted to only grab a section of information. For instance, I want everything from Big Numbers - 1002 only. I assume this would be a following text and a preceding text statement.

(imported comment written by donduke91)

I’m trying to create a property to retrieve HBA details for servers using fcinfo.exe /details > fcinfo.txt. The fcinfo.txt will have similar lines depending on how many ports the server has; eg, "adapter: " will show up twice for servers with 2 ports but with different text after the “:”

adapter: com.emulex-LP9002-0

node_wwn: 20:00:00:00:c9:41:3b:57

fabric: 10:00:00:60:69:e2:04:92

port_wwn: 10:00:00:00:c9:41:3b:57

osdevice: \.\Scsi3:

venid: x10DF

prodid: xF900

nports: 1

manfac: Emulex Corporation

sernum: P646C0ATEQO01I

model: LP9002

descrp: Emulex LightPulse LP9002 2 Gigabit PCI Fibre Channel Adapter

symblc: Emulex LP9002 FV3.92A3 DV5-1.11X1 NYCITASP2674

hwver: 2002606D

drvver: 5-1.11X1

optver: 3.22A0

fwver: 3.92A3

drvnam: elxstor

adapter: com.emulex-LP9002-1

node_wwn: 20:00:00:00:c9:41:3b:58

fabric: 00:00:00:00:00:00:00:00

port_wwn: 10:00:00:00:c9:41:3b:58

osdevice: \.\Scsi4:

venid: x10DF

prodid: xF900

nports: 1

manfac: Emulex Corporation

sernum: P646C0ATEQO01I

model: LP9002

descrp: Emulex LightPulse LP9002 2 Gigabit PCI Fibre Channel Adapter

symblc: Emulex LP9002 FV3.92A2 DV5-1.11X1 NYCITASP2674

hwver: 2002606D

drvver: 5-1.11X1

optver: 3.22A0

fwver: 3.92A2

drvnam: elxstor

How can I retrieve the txt after "adapter: " for each port. I tried using :

q: if exists file ((pathname of parent folder of regapp “besclient.exe”) & “\fcinfo.txt”) then following texts of firsts "adapter: " of lines whose (it contains "adapter: ") of file ((pathname of parent folder of regapp “besclient.exe”) & “\fcinfo.txt”) else “n/a”

A: com.emulex-LP9002-0

A: com.emulex-LP9002-1

How can I retrieve the output seperately for each "adapter: "?

Thanks.

Don D.

(imported comment written by BenKus)

Hey Don D,

Can you give some more details on what you are looking for? Are you asking how to get all the text after “adapter:” (not just on the same line as you have it now)? If so, what sort of format are you looking for? Do you want every value on a different line or do you want all the values concatenated together on one line?

Ben

(imported comment written by donduke91)

Hi Ben,

I want to create a retrieved property for each line in the file that has "adapter: ". I can use:

Adapter1 RP:

following text of first "adapter: " of (line 2 of file ((pathname of parent folder of regapp “besclient.exe”) & “\fcinfo.txt”))

Adapter2 RP:

following text of first "adapter: " of (line 22 of file ((pathname of parent folder of regapp “besclient.exe”) & “\fcinfo.txt”))

Instead of using 'line 2…" for Adapter1 or “line 22…” for Adapter2, is there any other way to get the data because some servers will have more than 2 adapters.

I hope this is clear.

Thanks.

Don

(imported comment written by jessewk)

Hi Don,

You have to define each RP individually so if there are N possible adapters, under your scheme you’d need N RP’s with each one defined separately.

I think you’re better off creating a single RP. If there are multiple results you have the choice of returning each of them individually or concatenating them into a single result using a delimiter.

Jesse

(imported comment written by KHaynes)

I’ve also been looking at using BES to gather HBA information and have recently come across the fcinfo tool. From what i can gather fcinfo uses WMI to gather the data from the MSFC_FCAdapterHBAAttributes class in WMI. The msdn link below details all of the attiributes that are stored in the class. Would it not be possible to simply gather the data directly from WMI rather than capturing the information from fcinfo and then extracting the data from a text file? I would have a go at this myself but unforatunately i know little about WMI and even less about relevance queries! Any gurus out there fancy having a look at this?

http://msdn.microsoft.com/en-us/library/ms809051.aspx

(imported comment written by BenKus)

Hi Khaynes,

It is probably possible, but I don’t have a fiber channel so I can’t really test…

Often these types of queries look like:

selects “* from MSFC_FCAdapterHBAAttributes” of wmi “xxxx”

It is the xxxx part that I don’t know about… this is the wmi class (like “root/cimv2”). If you can figure out the wmi root class, then this might work… Also, you want to make sure the query doesn’t take a very long time to run.

Ben