Simple EA - where is the error

Captainamerica
Contributor II

I am freaking a bit out. I am doing a very simple EA if onedrive exist and I have copied examples here from forum, but it does not work for some reason

#!/bin/sh

if [ -e /Applications/OneDrive/OneDrive.app ]; then
echo "<result>TRUE</result>"
else
echo "<result>FALSE</result>"
fi

exit

I know the path is like this and it exist and I update the inventory ? - I must be blind and cannot see the error

14 REPLIES 14

hlans
New Contributor II

Might be the missing space between .app and the ]

.../OneDrive.app ]; then

Captainamerica
Contributor II

No - still not found :(

jsherwood
Contributor

@Captainamerica Your issue is just a missing space between .app and ]

Apart from that, I tend to us -d to test as app bundles are actually just a directory .

#!/bin/sh

if [ -d /Applications/OneDrive/OneDrive.app ]; then
echo "<result>TRUE</result>"
else
echo "<result>FALSE</result>"
fi

exit

Captainamerica
Contributor II

Ok found it - this one was tricky. Even onedrive is in the "applications" stand as "onedrive". If I do check "get info" on that folder, the folder is actually named onedrive.localized

mschroder
Valued Contributor

Hm, I would add a space between '.app' and the ']'. I also would have used '-d' (is a directory) instead of '-e' (exists) , but in practice this should not make a difference, I assume very few people would create a file named '/Applications/OneDrive/OneDrive.app' ;)

mschroder
Valued Contributor

Uuh, seems I shoul'd not wait that long between reading and replying...

stevewood
Honored Contributor II
Honored Contributor II

A safer way to get the path to an Application, at least the way I handle it, is to either use ls from Terminal, or right click the app in Finder and hold the Option key down. The "Copy <app name>" turns into "Copy <app name> as Pathname". This works for anything in Finder, not just apps. That will give you the full pathname.

mm2270
Legendary Contributor III

I'm not sure where you were seeing a "OneDrive" folder in Applications, and then the OneDrive.app inside that. On my Mac, it's just /Applications/OneDrive.app No "OneDrive" directory before the actual app like what you have there.
Maybe different versions of Office installs put things in different paths, but I kind of doubt that.

Edit: Also, I'm curious why you'd even need such an EA since this is in the standard Applications path that Jamf already collects. Why use an EA to detect that? Isn't that redundant?

ryan_ball
Valued Contributor

Another way:

#!/bin/bash

if /usr/bin/find /Applications -name "OneDrive.app" -type d -maxdepth 2 -mindepth 1 | /usr/bin/egrep '.*' &>/dev/null ; then
    echo "<result>TRUE</result>"
 else
    echo "<result>FALSE</result>"
fi

scottb
Honored Contributor

I'm confused on this one as well. I have never seen the OneDrive.app in it's own folder - or maybe in 2011 days I dunno...

djdavetrouble
Contributor III

Why do this when App inventory is one of the main features of JAMF?

jhamil50
New Contributor III

I’ve seen this when there’s a copy of OneDrive installed from Mac App Store and from Microsoft’s CDN. Can you use a script from a policy to remove the duplicate if that’s what you’re trying to discover using the extension attribute?

tlarkin
Honored Contributor
$ if mdfind -name OneDrive -onlyin /Applications 2>&1 > /dev/null ; then echo "true" ; fi
true

the path is actually /Applications/OneDrive.app

jameson
Contributor II

If installing one drive from App Store it makes this strange folder in application, that has a different name that it is showing. Patch management will not find the one drive App Store version