Posted on 06-06-2019 01:38 AM
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
Posted on 06-06-2019 02:47 AM
Might be the missing space between .app and the ]
.../OneDrive.app ]; then
Posted on 06-06-2019 02:53 AM
No - still not found :(
Posted on 06-06-2019 02:57 AM
@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
Posted on 06-06-2019 03:04 AM
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
Posted on 06-06-2019 03:40 AM
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' ;)
Posted on 06-06-2019 03:41 AM
Uuh, seems I shoul'd not wait that long between reading and replying...
Posted on 06-06-2019 07:35 AM
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.
Posted on 06-06-2019 07:48 AM
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?
Posted on 06-06-2019 08:01 AM
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
Posted on 06-06-2019 08:31 AM
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...
Posted on 06-06-2019 08:50 AM
Why do this when App inventory is one of the main features of JAMF?
Posted on 06-06-2019 11:29 AM
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?
Posted on 06-06-2019 08:34 PM
$ if mdfind -name OneDrive -onlyin /Applications 2>&1 > /dev/null ; then echo "true" ; fi
true
the path is actually /Applications/OneDrive.app
Posted on 06-06-2019 10:04 PM
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