Posted on 07-21-2016 06:15 AM
I am trying to search all my machines for the presence of a local Google Drive folder. Borrowing from a script I have found in another thread I have set up an extension attribute with a script, but it is not recognizing the folder. Assuming the issue lies with the variable in the path to folder, but unsure how to rectify. (I am open to other options if extension attribute is not the way to go. New to the Casper Suite and still learning my way through) Thanks!
if [ -d "/Users/${loggedInUser}/Google Drive" ]; then
echo "<result>Has Work Folder</result>"
else
echo "<result>Does Not Have Work Folder</result>"
fi
exit
Solved! Go to Solution.
Posted on 07-21-2016 06:22 AM
@jcolucciello where are you specifying the the value for loggedInUser? I've seen people use the following for that:
loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
Posted on 07-21-2016 06:22 AM
@jcolucciello where are you specifying the the value for loggedInUser? I've seen people use the following for that:
loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
Posted on 07-21-2016 06:40 AM
@mpermann Adding that looks like it did the trick. Thanks so much for the quick and helpful response!
Posted on 07-21-2016 06:42 AM
Yes, ${loggedInUser}
is not being defined anywhere in your script. So its using a path of "/Users//Google Drive" since the username is blank, so of course its not finding it. You can add a variable for that like @mpermann shows above. There are several other options to grab the logged in user. Another one I use these days is:
stat -f%Su /dev/console
And there's a python Apple approved way out there as well if you search around on here.