Extension attribute not displaying stdout

wgregorian
New Contributor

I have a simple extension attribute that's supposed to display an Agent version:

#!/bin/bash

# Check to see if the SentinelOne agent is installed.
# If the agent is installed, report the agent
# version.

printf '<result>'
if result=`/usr/local/bin/sentinelctl version | awk '{print $2 $3}'`; then
  printf "$result"
else
  printf "Unavailable/Not Installed"
fi
printf '</result>'

When I run this locally on my machine, it works, but running it as an extension attribute doesn't seem to work.

Any suggestions on how to debug this issue?

1 ACCEPTED SOLUTION

hkabik
Valued Contributor

Try:

#!/bin/bash

# Check to see if the SentinelOne agent is installed.
# If the agent is installed, report the agent
# version.

if [ -f "/usr/local/bin/sentinelctl" ] ; then 
    RESULT=$( /usr/local/bin/sentinelctl version | awk '{print $2 $3}' )
else
    RESULT="not installed"
fi

echo "<result>$RESULT</result>"

View solution in original post

3 REPLIES 3

wgregorian
New Contributor

I also tried:

#!/bin/bash

# Check to see if the SentinelOne agent is installed.
# If the agent is installed, report the agent
# version.

if [ -f "/usr/local/bin/sentinelctl" ] ; then 
    RESULT=`sudo /usr/local/bin/sentinelctl version | awk '{print $2 $3}'`
else
    RESULT="not installed"
fi

echo "<result>$RESULT</result>"

Just to see what happens :)

hkabik
Valued Contributor

Try:

#!/bin/bash

# Check to see if the SentinelOne agent is installed.
# If the agent is installed, report the agent
# version.

if [ -f "/usr/local/bin/sentinelctl" ] ; then 
    RESULT=$( /usr/local/bin/sentinelctl version | awk '{print $2 $3}' )
else
    RESULT="not installed"
fi

echo "<result>$RESULT</result>"

wgregorian
New Contributor

Super weird. It works when running script via Policy, but as an extension attribute, it does not.

edit: flushPolicyHistory fixed it.