Action script for Linux(Centos 7), not working

Hello all, first time posting so please forgive if in wrong category.

I am trying to write an Action Script that will find the McAfee agent version and output it to a file. The linux script works on the linux system, but can’t get it to work all the way through with the Action Script.

Here is my Action Script:
// create a file with shell script commands using the “appendfile” action, for instance find the McAfee agent version, then output a file with results
appendfile #!/bin/sh
appendfile /opt/McAfee/agent/bin/cmdagent -i | sed “4,$ d” | sed “s/Version: //g” | sed -sn 3p > agent

// rename the script
move __appendfile agentscript

// give permissions to run the script
run chmod 777 agentscript

// run the script
wait sh agentscript

Here is what the log output shows me:

The confusing part is… the command succeeded, but bigfix reports it as failed.

Hi brapoel,
I notices in the log that the fixlet is set as “Not Relevant”.
Are you writing a Fixlet or a Task ?

The Fixlet would fail if the applicability relevance is true after that the fixlet has run.
Does the command succeed if you run “sh agentscript” from the local command line ?
Why don’t you use bash instead of sh ?

Greetings,

I am running a fixlet. The command does not succeed, because the agentscript is never created (I haven’t seen it yet, or I am not looking in the correct place).

Will give bash a try and see what happens.

f.pezzotti, here is the result of using bash… still comes back as failed in Bigfix

Can you post please the applicability relevance ?

Note that this time the ActionScript has failed.
The wait command returned 127 ( command not found ).
Maybe the full path is required (/bin/bash or /usr/bin/bash).

The file is created under /var/opt/BESClient/__BESData/actionsite/
Try use this path to the bash command.

Here is my relevance:

A co-worker was helping out and explained that I may need to add more relevance and possibly create a custom property for relevance to see.

1 Like

You would need to make this a task or change it so that the success criteria was that it completed all lines of the action.

A fixlet made into an action by default has to have the original relevance go false. I don’t think that your action makes the OS not be Linux anymore :slight_smile:

AlanM,

That worked… thanks for the tip. But I can’t seem to find my file agent?

I have changed the action script a little.

Can you be a bit more specific?

I see a couple of things to comment on there, but I don’t know whether any are your problem.

Where you create the output file ‘agent’, you aren’t setting a path to the output file. So it may end up in the ´BESClient/__BESData/sitename´ directory, which is periodically synced by the client - which will delete your output file.

Also, a good practice is to use ´delete __appendfile´ before creating it, to ensure there is no old content hanging around in the appendfile first.

When you execute the new script via bash, you are assuming it’s in the actionsite folder. The actual path can vary based on the operator (only a master operator updates the actionsite, and you really shouldn’t be using the master operator account to send client actions); the fixlet source site; and whether the action was targetted dynamically or statically. So generally you should either move the shell script to a known directory path, or use relevance substitution to generate the path such as ´{pathname of client folder of current site}/agentscript´

I found my file and script works just fine… thanks for the assist