Trying to parse value from text file and add to property

Hi, I’m trying to parse a value from a file like this (version may not always be on third line):

  1. #some text
  2. #Sun Mar 16 11:02:28 EDT 2025
  3. installed.version=8.x.x.x.x

with this relevance and assign that value (8.x.x.x.x) to a property “such-n-such-version”:

  • (substring after “installed.version=” of it) of (line of file “/pathtofile/servername/installed.version”)

note there is a server name in the path, so will need to wildcard it somehow. I have tried many variations of this relevance, but keep getting various different errors like “Singular expression refers to nonexistent object.” Thanks, for any help!

Hi @bigfixit, you can give this a try to see if this meets your needs:

following texts of firsts "=" of lines whose (it starts with "installed.version=") of files "installed.version" of folders of folders "/pathtofile"

-Gus

Hey @gus, That seems to be a step in the right direction… no error now, just ‘none’ as value… does the * in the path cause any problems? Thanks, for your help!

Welcome to the forums.

I need to understand more of what you are asking.

Is “/pathtofile/servername/installed.version” the source file to get the version from? I am assuming this is not an UNC path, this is a path to a file located in a folder?

Do you have a list of server names or you need it to scan the entire folder and get the same file name under each sub folder?

Do you also need to know the action to put the data into a property?

Hey @D.Dean, Yes the “/pathtofile/-servername-/installed.version” is the source of the version… No not unc, just file path on linux box… server name in the path will be unique on each box, but rest pf path is the same on each box… Yes, it would be very helpful to know what action would put the version into the property… thanks!

btw I am using “/pathtofile/*/installed.version” as the path currently where the asterisk is the servername…

Being linux, I am going to pass this to others. I have very little experience with Linux.

However, is the server name in the file path going to be the same as the server name running the task? That info will help others.

No worries… I appreciate the help! Yes, the sever name in the path will be the same as the actual server running the task…

Hi @bigfixit, I would not put a wildcard “*” in the path. Here is some additional information as I’ve attempted to recreate your ask. Notice that I don’t use the name of my server in this example below and my path begins at /tmp.

Q: following texts of firsts "=" of lines whose (it starts with "installed.version=") of files "installed.version" of folders of folders "/tmp"
A: 8.x.x.x.x
T: 3859

Q: pathnames of files "installed.version" of folders of folders "/tmp"
A: /tmp/rhelserver04/installed.version
T: 364

-Gus

@bigfixit can you please provide a sample of this file?
There are different inspectors for text files, XML, Json etc… so if we have the source it will help ,make sure to remove any sensitive information

@orbiton, here’s a sample of the source file wiht the version in it…

  1. #some text
  2. #Sun Mar 16 11:02:28 EDT 2025
  3. installed.version=8.x.x.x.x

Thanks @gus, unfortunately, the server name is hardcoded in the path to the source file on each server… and, I have no way that I know of to create a relevance that would use the server’s actual name and substitute it in the path as a parameter…

That should be easy then. “computer name” can be used in the relevance.

@D.Dean, Unfortunately, there are potentially 100’s of servers where the software is installed. It sounds like I would have to write that many relevances…

I am confident a single task can be created to get the information you want.

@JasonWalker is often my go to when I have tough questions.

@bigfixit did you test the relevance that I provided. Make 1 modification to the relevance and simply replace “/tmp” with the path to the server name directory. So if this is the directory path to your file:
/pathtofile/servername/installed.version
Then simply replace /tmp with /pathtofile. Don’t include a wildcard or servername in the path. What is the results?

@gus, I am trying now… it looks like it is coming back as ‘none’. So, I am trying to reach the server owners to verify the path and file that they gave me is actually there… I’ll let you know what they say… thanks, for your help so far.

How does this fair in your environment?

Q: following texts of firsts "=" of variables whose (it starts with ".installed.version") of files "installed.version" of folders ("/etc/" & (computer name as lowercase))
A: 8.x.x.x.x

If the folder name is the same case as the hostname you may need to avoid casting computer name as lowercase, and change “etc” to whatever your “pathtofile” is :wink:

1 Like

So you mean the file structure is regular text? It is not in a structure of XML or JSON?

Hey @SLB, I will definitely try that… thanks!

@orbiton, yes, just straight text as the example I sent…