Relevance to read values from manifest file

I have a manifest file with a single line in it that I need to read the values from.

name=myfile.zip sha1=71266dd68ebd07d4bc6ecaea519017905ff5e621 size=3929 URL=http://server/folder/myfile.zip

I need relevance to get each of the values. I can sort of work up some stuff to grab some but not all. anyone have some tricky trick way to get each one univerdally?

1 Like

This does it shout of URL…

substrings between " " of lines whose ( it contains "sha1=") of file "c:\tmp\manifest.found"

Found it
preceding text of first " " of ((substring after ā€œsha1=ā€ of line 1 of file ā€œC:\tmp\manifest.foundā€) as string)

preceding text of first  " " of ((substring after "name=" of line 1 of file "C:\tmp\manifest.found") as string)

so what should the output look like?

You want each value as a separate relevance statement individually?

This will fail if there is an empty line added to the beginning of the file, which may never happen. If the file is always 1 line long, then there is no need to reference line 1 specifically, but if it is a very large file, then limiting the relevance to the first few lines is a very good idea.

This is all of the values as a whole:

(it as trimmed string) of ( (following text of first "=" of it | it) of substrings separated by " " of it) of lines of files "c:\tmp\manifest.found"

I didn’t test this.

To get just the name, I would do it this way:

preceding texts of firsts  " " of following texts of firsts "name=" of lines of files "c:\tmp\manifest.found"

If the as string is required:

preceding texts of firsts  " " of following texts of firsts "name=" of (it as string) of lines of files "c:\tmp\manifest.found"

Your right, but in this case I’m always expecting 1 row.

That said, I like your version better. Thanks!

1 Like

It is interesting how there are things like substrings between, after, before and preceding, following text

I think in some cases these are aliases of the same or similar thing. I don’t pay much attention to it and just get something to work but I should look into it more and figure out the differences… and if there is any speed difference.

1 Like

ā€œThere’s always a Regular Expressionā€ Ā© :grin:

There’s a general regex used in the BESDownloadCacher tool that I’ve seen referenced somewhere, and I duplicate it in a custom download cacher that I wrote to only precache files from fixlets that are relevant in my environment. It parses all of the download, download now, download now as, prefetch, and add prefetch item statements from fixlet action scripts.

If it sounds useful I can dig it up tomorrow.

1 Like

That would definitely be useful.

I’m always up on hardening my regex skills!

My Web Report runs this to identify the relevant downloads. A custom Web Report Archive Handler saves this to an output file, and I feed the file as an input to a curl script; this way I only precache the downloads that are relevant to at least one host in my environment.

For each download, I’m only preserving the expected sha1 and the URL; after each download I check the sha1 to ensure I have the correct file. The regex could be adapted to preserve the size and sha256 as well.

The normal BESDownloadCacher has two major limitations in my view - it downloads every file (relevant or not); and the method it uses to check whether a given file is already precached is very slow (for every file download, it retrieves a list of every file from sha1 and compares, which takes several hours with a large cache).

concatenation "%0d%0a" of unique values of (item 0 of it & ", " & item 1 of it) of (parenthesized parts 2 of matches (case insensitive regex "(sha1:|sha1=)([^[:space:]]+)") of it , matches (case insensitive regex "((mailto\:|(news|(ht|f)tp(s?))\:\/\/){1}\S+)") of it)of ((matches (case insensitive regex "^[[:space:]]*(download|prefetch|download now|download now as|add prefetch item).*$") whose (it does not contain "MANUAL_BES_CACHING_REQUIRED" and it does not contain "127.0.0.1:52311/" and it does not contain "downloadserver:52311/" )of substrings separated by "%0a" of scripts of actions whose (exists script whose (exists matches (case insensitive regex "((mailto\:|(news|(ht|f)tp(s?))\:\/\/){1}\S+)") of it) of it) of it) as string) of fixlets whose ((fixlet flag of it or task flag of it) AND applicable computer count of it > 0) of bes sites whose (external site flag of it or custom site flag of it)

Result outputs look like:

008e388b0f3ec3e761841d509f203df27a2e4777, http://software.bigfix.com/download/tema/bzip2/linux-x86_64_v2/bzip2

00fe000ecf7a11b16edbf15e584f39c707c5b391, http://download.windowsupdate.com/d/msdownload/update/software/secu/2018/02/windows10.0-kb4074588-x64_delta_00fe000ecf7a11b16edbf15e584f39c707c5b391.msu

0132284fead921bc13b6e121b37f26a923cc5c77, http://download.microsoft.com/download/9/A/C/9AC1D648-02E1-43A0-A193-B02144F37041/Windows8.1-KB3060746-x64.msu

01510a07c6d09de56bff1472ef2d906e21d4a0f6, http://software.bigfix.com/download/bes/92/BESAgent-9.2.8.74.ppc64_aix61.pkg
1 Like

I think for parsing your file it would be something like

(parenthesized parts 2 of matches (case insensitive regex "(sha1:|sha1=)([^[:space:]]+)") of it , parenthesized parts 2 of matches (case insensitive regex "(name:|name=)([^[:space:]]+)") of it ) of lines of file "X"

where ā€˜item 0’ will give the sha1, ā€˜item 2’ will give the name, and you can duplicate those as needed to get URL, size, and (if present) the sha256 values.

1 Like