Extension Attribute/Scripting Help (deploying Digital Guardian DLP software)

timlarsen
Contributor

Hey All,

Wondering if anyone out there has: A) installed or worked with Digital Guardian DLP software for Mac?
B) successfully created an extension attribute that reports the agent version installed?
C) mastered the rare art form of text manipulation in the command line and can help me regardless of the software I'm reporting on?

DG's command line binary, "dgctl" has an easy way to report on the currently installed version by typing the following into a Terminal window: "dgagent/dgctl --version" which outputs the following (excessively verbose in my opinion) info:

2017-03-03 16:55:14.968 dgctl[19465:70794] DGAgent for Mac OS X version 7.1.4.0004
2017-03-03 16:55:14.969 dgctl[19465:70794] OK

I've tried piping into tools (and combinations thereof) using sed, grep, awk, cut etc. and no matter what I try, I just get a blank response and no output. I'm looking to cut out everything except the "7.1.4.0004" ideally, but getting frustrated that I can't seem to modify the text at all.

Even by removing any pipes into txt manipulation and just attempting to return the two line result with an echo returns nothing, i.e.

#!/bin/bash

if [ -d /dgagent ] ; then

    dgVersion=$( /dgagent/dgctl --version )

    echo "DG version is $dgVersion"

else

    echo "<result>Not Installed</result>"

fi

exit 0

Before you ask, no, there does not appear to be any plist, log or other static/clear text item installed that I could use instead to report on the version number. Seems like you must get the information by running this command.

Any expert scripting/EA help out there would be very much appreciated! Thank you!

1 ACCEPTED SOLUTION

iJake
Valued Contributor

Try this:

dgagent/dgctl --version 2>&1 | head -n1 | awk '{print $10}'

View solution in original post

9 REPLIES 9

iJake
Valued Contributor

Seems like you should be able to do:

dgagent/dgctl --version | head -n1 | awk '{print $10}'

Assuming the result is always output that way.

timlarsen
Contributor

Thank you @iJake for the suggestion! Unfortunately no luck and same results... It is almost as if Verdasys (Digital Guardian developer) follows some kind of non-standard output method that is unable to be manipulated and is not clear text. I'll keep trying different stuff and see what the vendor says. Thanks again.

iJake
Valued Contributor

Try this:

dgagent/dgctl --version 2>&1 | head -n1 | awk '{print $10}'

timlarsen
Contributor

Yes, that did it! Thanks, should have thought of that! Appreciate the help!

iJake
Valued Contributor

Glad to help!

ShadowGT
New Contributor III

If your interested I can share a nice bundle of DG related EAs I have created to assist in its management and deployment. I am in the process of updating and posting my github, so you can either wait or reply this post and I will provide via other means.

-Frank J

michaelmcgaw
New Contributor III

@ShadowGT Your DG-related EAs would be appreciated.

-- Mike

ShadowGT
New Contributor III

I will be posting more as it scrub and get clearance, but here are the basic ones. I hope it helps:

ShadowGT2000 Repo - DigitalGuardian

easyedc
Valued Contributor II

Just saw this, here's the script I have to check the version after working with DG a few years ago.

/dgagent/dgctl --version 2>&1 | grep Mac | awk '{ print $NF}'

which I threw into an EA

#!/bin/sh

DGA=$(/dgagent/dgctl --version 2>&1 | grep Mac | awk '{ print $NF}')

if [[ -z $DGA ]] ; then
  echo "<result>Not Installed</result>"
else
  echo "<result>$DGA</result>"
fi

My only suggestion is using

awk '{ print $NF}'`

over

awk '{print $10}'

In the off chance that that response isn't the 10th string in the future, where as $NF prints the last string. As a side note, I have the unique pleasure distinction luck pain of being the first Mac DG deployment (so they say). It was really bad early going, when they'd just throw code to us untested for us to "work" with.