File path in lines of file relevance

I have a need to read certain line from a certain file and use that information in a property but the problem is that the file path differs between endpoints. I know that I could read the prefix of the proper file path from another file but I’m unable to use that information in “lines of file” relevance. This is the relevance that I thought would work but obviously it does not.

if (name of operating system starts with "Linux" AND exists file "/etc/init.d/ITMAgents1") then following text of first "CTIRA_HOSTNAME=" of it of lines of file "(following text of first "CANDLEHOME=" of it of lines of file "/etc/init.d/ITMAgents1")/config/lz.environment" else "Not Found"

If there is no chance to use this kind of approach, what options do I have?

Hi!

It looks like the way you’re trying to nest it doesn’t jive with how relevance concatenates things.

We should try building up to the relevance we want by writing small segments until something stops working. I dont have a linux box so some of these might need adjustment but here we go :slight_smile:

Get the first file:

file "/etc/init.d/ITMAgents1"

Get the CandleHome value:

following texts of firsts "CANDLEHOME=" of lines of files "/etc/init.d/ITMAgents1"

Get the folder:

folders (following texts of firsts "CANDLEHOME=" of lines of files "/etc/init.d/ITMAgents1")

Get the lz.environment file in that folder:

files "config/lz.environment" of folders (following texts of firsts "CANDLEHOME=" of lines of files "/etc/init.d/ITMAgents1")

Get the CTIRA_HOSTNAME from that file:

following texts of firsts "CTIRA_HOSTNAME=" of lines of files "config/lz.environment" of folders (following texts of firsts "CANDLEHOME=" of lines of files "/etc/init.d/ITMAgents1")

If this doesn’t work let me know which relevance statement above that it started failing with

Yeah, that’s something I thought as well :slight_smile:

This is where things go wrong (there is no answer) and because of this the rest of the relevance doesn’t work either:

Q: folders (following texts of firsts “CANDLEHOME=” of lines of files “/etc/init.d/ITMAgents1”)
T: 2332

However, I found a way to accomplish my goal, which was to get the piece of information of the certain file and eventually make a property (or a client setting to be specific) of it. I decided to use action script instead of plain relevance and here is how I did it:

if {name of operating system starts with “Linux”}
createfile until _end

#!/bin/sh

export TIVCFG=grep ^CANDLEHOME /etc/init.d/ITMAgents1|cut -d\= -f2|tr -d \"/config && [[ -f $TIVCFG/lz.environment ]] && grep ^CTIRA_ $TIVCFG/lz.environment > /iem/tivoli_name.dat || grep ^CTIRA_ $TIVCFG/lz.ini > /iem/tivoli_name.dat
_end
move ___createfile “/iem/get_ctira_hostname.sh”
endif

// Run script
wait chmod +x “/iem/get_ctira_hostname.sh”
wait sh /iem/get_ctira_hostname.sh

// Set CTIRA_HOSTNAME
if {exists file “/iem/tivoli_name.dat” AND exists lines of file “/iem/tivoli_name.dat”}

setting “CTIRA_HOSTNAME”=“{following text of first “CTIRA_HOSTNAME=” of it of lines of file “/iem/tivoli_name.dat”}” on “{parameter “action issue date” of action}” for client

endif

Anyway, thanks @strawgate for your input!