Posted on 02-06-2019 09:18 AM
I am beginner in scripting, but managed to find the following and it is working
#!/bin/bash
if [ -d /Library/Updates/041-31306 ]; then
echo "<result>TRUE</result>"
else
echo "<result>FALSE</result>"
exit
Is there a way to build in another path into the same EA - So both Library1 and library 2 must exist (TRUE/FALSE) - or must I create 2 seperate EA for each?
Posted on 02-06-2019 09:32 AM
#!/bin/sh
if [[ -e /Library/Updates/041-31306 && -e /other/file/path ]]; then
echo "<result>TRUE</result>"
else
echo "<result>FALSE</result>"
fi
I tested on my machine with two dummy files. If both exist it will echo true if one is missing it will echo false. Hope this helps.
Posted on 02-06-2019 09:38 AM
#!/bin/bash
if [[ -d "/path/to/folder/subfolder1" && -d "/path/to/folder/subfolder2" ]]; then
echo "<result>TRUE</result>"
else
echo "<result>FALSE</result>"
fi
Posted on 02-19-2019 11:00 PM
Sorry - just found out that I initially wrote this topic the wrong way.
I want that if Folder1 OR folder2 exist it must be TRUE. I wrote that both folders must exist in the opening post
Posted on 02-19-2019 11:22 PM
@Captainamerica In either example above, change &&
to ||
and it should give you the results you're looking for.
The &&
means 'and' (obviously), and ||
means 'or'
Posted on 02-20-2019 12:20 AM
Thank you :)
Posted on 02-20-2019 02:23 AM
Maybe a bit off topic. But on the mac I run the above script but the extension attribute still show "false" even the folder is there. If I run the same scipt in coderunner on the mac, it shows true. So code is working
I have of course run a recon and inventory is also updated according to Jamf
Has anyone expierenced that before ?
Posted on 02-20-2019 06:13 AM
What are the paths to the folders exactly? Also, can you post the exact script code you're using?
Posted on 02-20-2019 06:37 AM
Try this:
#!/bin/bash
if [[ -d "/path/to/folder/subfolder1" ]] || [[ -d "/path/to/folder/subfolder2" ]]; then
echo "<result>TRUE</result>"
else
echo "<result>FALSE</result>"
fi