Skip to main content

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?

#!/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.


#!/bin/bash

if [[ -d "/path/to/folder/subfolder1" && -d "/path/to/folder/subfolder2" ]]; then
echo "<result>TRUE</result>"
else
echo "<result>FALSE</result>"
fi

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


@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'


Thank you :)


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 ?


What are the paths to the folders exactly? Also, can you post the exact script code you're using?


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

Reply