How do I assign variables from data extracted from a file

(imported topic written by SystemAdmin)

For example:

I have a file containing the following , delminited data

I want to apply firmware updates if the commpared values of these 4 are out of date.

Current values of the 4 levels my type are contained in the file.

Once they are extracted, I would like to assign them to a variable and use that value in if $BIOS=1.19

cbcbc004mm,14,UXPRF161,HS21,8,16241,00:1A:64:4F:5A:38,00:1A:64:4F:5A:3A, , ,99W5135,BIOS,BuildID,BCE143AUS,RelDate,12/09/2009,Rev,1.19,DIAG,BuildID,BCYT28AUS,RelDate,03/07/2008,Rev,1.06,SYSMGMT,BuildID,BCBT60A,RelDate,Not Available,Rev,1.20,cKVM,Rev,1.4.11.43

I need to extract all 4 values following each Rev

BIOS: 1.19

DIAG: 1.06

SYSMGMT: 1.20

cKVM: 1.4.11.43

So, in summary I want to extract the versions and compare to a static value, if not match, run commands to upgrade. So need to 1) extract a value, )2 puth that value in a $Variable to do if, command endif

(imported comment written by NoahSalzman)

Was the answer

here

enough to get you going?

(imported comment written by SystemAdmin)

Yes for the vertical example, but can relevance query a file delimited with “,” commas?

If so, can you provide a few examples…

Thanks

Jeff

(imported comment written by SystemAdmin)

If the number of commas and the position of where the data is remains consistant, you could try this. Here I’m assuming that the 18th item is the bios, 25th is diag, etc. Tuple items start at 0, which is why I’m looking at 17, 24, 31 and 34.

Also, tuple strings contain a comma and a space. I’m splitting your line apart by commas, trimming it and putting it back together. That’s because you have some items with a space as a value and the real data does not. See the recent post: http://forum.bigfix.com/viewtopic.php?id=6302

So comparing the 4 items, it could be:

(tuple string item 17 of it = “1.19” and tuple string item 24 of it = “1.06” and tuple string item 31 of it = “1.20” and tuple string item 34 of it = “1.4.11.43”) of (concatenation ", " of (it as trimmed string) of substrings separated by “,” of “cbcbc004mm,14,UXPRF161,HS21,8,16241,00:1A:64:4F:5A:38,00:1A:64:4F:5A:3A, , ,99W5135,BIOS,BuildID,BCE143AUS,RelDate,12/09/2009,Rev,1.19,DIAG,BuildID,BCYT28AUS,RelDate,03/07/2008,Rev,1.06,SYSMGMT,BuildID,BCBT60A,RelDate,Not Available,Rev,1.20,cKVM,Rev,1.4.11.43”)

Paul

(imported comment written by SystemAdmin)

I’m new to this relevance language and it’s very confusing to me… Is there any bigfix docs that have real examples, not just partial syntax?

what I need is your tuple example in a relenace statement to query a file with the current values.

For example if the item 17 is 1.19 and I want to upgrade to 1.20, I need the relevance statement to compare the item 17 value to 1.20, theu failing the relevance so I can execute the action script to upgrade

(imported comment written by SystemAdmin)

If you didn’t find it yet, this is where you should start:

http://support.bigfix.com/fixlet/

All of the fixlet documentation is here, along with the Fixlet debugger.

Putting it together isn’t hard. Let’s assume you have a filename called biosdata.txt, that each line contains the comma delimited data you gave as your initial example.

So having Bigfix parse every single line would be…

lines of file “c:\foo.txt”

We could check to see if there’s at least 1 line in that file that has the bios info you’re looking for. For this we add a “whose” clause for each line…

exists line whose () of file “c:\foo.txt”

So for the above, the inside () of the “whose” clause will evaluate each line of the file. We put what we’re looking for in there. The last “of it” inside the “whose” example below refers to the object that the whose is referring to (each line of the file).

So to check to see if there’s at least 1 line that has those 4 pieces in there would be…

exists line whose ((tuple string item 17 of it = “1.19” and tuple string item 24 of it = “1.06” and tuple string item 31 of it = “1.20” and tuple string item 34 of it = “1.4.11.43”) of (concatenation ", " of (it as trimmed string) of substrings separated by “,” of it)) of file “c:\users\bmispah\desktop\foo.txt”

The reason why I have “exists line” rather than “exists lines” is because I’m only interrested if there’s at least 1 single line that meets the criteria. Actually, it makes no difference if we check for “line” vs “lines” because the evaluation should stop after it detects 1 line that meets the condition.

Hope that helps.

Paul