Results of the below commands

Hi Team,

please help me how to get the results for these commands .

getenforce
sestatus

Thanks

Hi @ark,

Guessing you mean how to pull them back in an analysis property?

You’d have a task to capture the command output to a file, something like:
wait bash -c "sestatus > /tmp/sestatus.txt"

And a property to read the results file, something like
lines of file "/tmp/sestatus.txt"

Thanks a lot
it’s working.

Can you please help me on below also.

appendfile multipath -ll|grep -i failed

powermt display

You would do it the same way; it’s not affected by pipes:
wait bash -c "multipath -ll | grep -i failed > multipath.txt"

You would have to escape any double-quotes, though ( " -> \" )
because you’re inside the quotes,
and double all beginning curly brackets ( { -> {{ )
or else they’ll get interpreted as BigFix Relevance substitution.
https://developer.bigfix.com/action-script/guide/substitution.html

And a property to read the results file, can I use below
lines of file “/tmp/multipath.txt”

Can you also please help how to write the property and relevance for below commands

powermt display

Yes – in the property, you read the file you generated in the task.

So you could use a property like this:
lines of file "/tmp/multipath.txt"

…to read the results of a command like this:
wait bash -c "multipath -ll | grep -i failed > /tmp/multipath.txt"

(the /tmp/multipath.txt matches in both)

For ‘powermnt display’ just do the same thing you did for ‘sestatus’ and ‘multipath -ll | grep -i failed’ – it’s the same pattern: output a command result to a file in a task, then read the file in a property.

Hi,

I used below but not working.
wait bash -c "powermt display > /tmp/powermt.txt"
lines of file “/tmp/powermt.txt”

Hi @ark,
The names have to match – try lines of file "/tmp/powermt.txt"
Also it’s a good idea to avoid spaces in filenames in general
(e.g. “/tmp/powermt display.txt” would probably cause you trouble even if it matched the bash line)

Hi,

I used below but not working.
wait bash -c "powermt display > /tmp/powermt.txt"
lines of file “/tmp/powermt.txt”

Hi @ark
I don’t have powermt on a system so can’t test that for you…
but based on a quick google search I wonder if you might mean powermt display dev=all ?

It’s a good idea to test the commands you want to run on the command line first, and make sure they produce the results you want non-interactively. There’s no user interaction when running commands in a BigFix task.

If you don’t get the result you expect in the lines of file property, then inspect the file manually to verify the result you’re expecting is there.

Go do some experimenting, and have fun!

1 Like

Just wanted to check: is there any way I can get the result of the below command directly from the analysis without executing the task to capture the command output to a file and reading the result of the file separately.

I wanted to capture the real time output of below command from ubuntu device.

“nsclient show-status"
or
"opt/nsclient/nsAgent show-status”

Thanks in advance

Negative, you’d have to execute a task, save the output to a file, and then read the file contents.

Reading the file contents could be done with an Analysis, or with the Query app to run the relevance as a one-time task.

Thank you for the update.

Basically, I was attempting to use bigfix analysis to capture the current status of the application services (systemctl), but I was unable to do so for the application services status on Ubuntu devices.

Please let me know if there is a way to analysis the systemctl status and capture it.