Send output from a Bigfix custom action Linux shell script to Bigfix server?

Is there a way to send output from a Bigfix custom action Linux shell script that is run on multiple Linux targets to the Bigfix server itself so that one would not have to login to each Linux server individually to verify that the script ran correctly?

For example, a simple custom action shell script might run a single command to check the version of an application on a set of targeted Linux servers. Can that output be captured centrally on the Bigfix server in a log file or some similar way?

@bfmyee, please take a look at my HCL - Ubuntu - APT Dist-Upgrade with Autoremove fixlet in my personal GitHub. This fixlet will bubble up the return code from the wait command in the Action Script. Please make sure that your Linux shell script doesn’t somehow suppress any error/exit codes. For a more involved example, please take a look at my Linux-Watchdog content and Bash scripts. Hope this helps.

Hello cmcannady, Sorry, I don’t quite understand how your action script works to “bubble up” the return code. I’m looking for more than just getting a return code. For example, I have this super simple Bigfix shell (sh) action script that works to write to a log file on the server while also emailing a recipient. How could I get this output sent to the Bigfix server? Reason why is because I will have other more complicated scripts that will be targeted to multiple Linux VMs and I’d like to see the output for each in one central location instead of spread out everywhere. BTW, I use ‘sh’ to create my action scripts because the “Shell Script to Action Script Conversion Utility” in https://bigfix.me/content/shelltoaction never worked for me. Thx, Mike

#!/bin/sh

Hello test script

logfile=/tmp/hello.log
/bin/cat /dev/null > $logfile

Send echo output to log file and mail output to recipient

echo "hello on date" | tee $logfile | mailx -s “test from $HOSTNAME” recipient@somecompany.com

@bfmyee, if you want more than just the exit/return code from the bash script that’s been executed via BigFix, then you’ll have to redirect the output of interest to an execution or other log file and then have an appropriate analysis to report back those details.

Take a look at the “Shell Shock” fixlet and analysis (CVE-2014-7169) located in the “Patching Support” external site for an example of this two part solution.

Hello, thanks again for your reply. I looked at that fixlet and it’s in two parts. First the fixlet itself and for the second part I can, "activate an analysis 1829 “Shell Shock Bash Vulnerability (CVE-2014-7169) Status” ". However, I could not find this analysis in my Bigfix console nor could I find it online to download. Where can I find this analysis? Thx!

@bfmyee, both the fixlet and analysis mentioned in my prior post are available by default when subscribed to the “Patching Support” external site. If you’re unable to locate the fixlet and/or analysis in question, I’d imagine said content may be hidden.

@bfmyee

I was looking for this today as well and found what I think you are looking for

to get the output of ls > mydir.txt, I had to wrap in shell.

wait sh -c "ls > mydir.txt"

more info here:

1 Like

Hello brolly33. Sorry that it’s taken me until now to respond. I tried this in a BigFix Action sh script (/bin/wait sh -c “ls > ls.txt”) but it didn’t work. Where does the “ls.txt” file go? I performed a search on the C: drive of the BigFix server but found nothing. It’s not on the Linux server where I ran it from either. Thx.

Brollys script just writes the ls output locally on the bes client. What you are looking for might be the “archive and uplod manager” which might be an alternative to using an analysis.

I would highly appreciate to get a more convenient way to gather some files as a one time action. On the other hand, as BigFix works on highest access level, this might cause security issues.