Extension Attribute - help needed creating one that looks for /Users/Shared/test directory

donmontalvo
Esteemed Contributor III

I'm trying to create an Extension Attribute that can look for the existence of a directory named "Test" in a known path. I do an Advanced search, selecting the Extension Attribute and entering "is = Yes"...or entering "is = No"...but the search comes up dry. I manually confirmed that the /Users/Shared/test directory exists on one computer, but does not exist on the other.

Here's what I have...any ideas how I can get this to work?

Data Type = String Input Type = Populated by Script Script: #!/bin/bash directory="/Users/Shared/test" if [ -d $directory ]; then echo "<result>Yes</result>" else echo "<result>No</result>" fi

Thanks,
Don

--
https://donmontalvo.com
4 REPLIES 4

stevewood
Honored Contributor II
Honored Contributor II

If you are checking to see if it exists, why not use the exist flag in the
On Thu, Aug 5, 2010 at 2:15 PM, Don Montalvo <donmontalvo at gmail.com> wrote:
If statement:

#!/bin/bash directory="/Users/Shared/test" if [ -e $directory ]; then echo "<result>Yes</result>" else echo "<result>No</result>" fi

donmontalvo
Esteemed Contributor III

Either would work, I'm just used to using "-d" when looking for directories.

Tried it with "-e" without luck.

Don

--
https://donmontalvo.com

Not applicable

Don,

I know I am a little late on this, just saw it. I just tried it and it
worked for me. If you already have it figured out, then just disregard,
otherwise let me know if it worked for you.

Sean

#!/bin/sh
#To check for presence of "test" directory in the Users/Shared location

#Check to see if Absolute call in
if [ -d "/Users/Shared/test" ]; then result="Yes" echo "<result>$result</result>"
else echo "<result>No</result>"
fi

donmontalvo
Esteemed Contributor III

Hi Sean,

Interesting! I'm going to give this another try.
I really want to be able to use Extension Attributes, specifically to check for proper install and running process on some agents we're deploying (to start). :)

Thanks,
Don

--
https://donmontalvo.com