Posted on 11-07-2017 04:12 AM
if you go into JAMF there is a script to block touch facebook, but it doesn't work.
I have look at the script, and I can't see anything wrong.
SUCCESS=0
domain=facebook.com
needle=touch.$domain
hostline="127.0.0.1 $needle"
filename=/etc/hosts
grep -q "$needle" "$filename" # -q is for quiet. Shhh...
if [ $? -eq $SUCCESS ]
then
exit 0;
else
# If the line wasn't found, add it using an echo append >>
echo "$hostline" >> "$filename"
# Let's recheck to be sure it was added.
grep -q "$needle" "$filename"
if [ $? -eq $SUCCESS ]
then
exit 0;
else
exit 1;
fi
fi
Help
Anne
Posted on 11-07-2017 06:20 AM
Hi Anne
It looks like you found my script from this Jamf Nation thread. It looks like some lines were combined into one by accident.
If you look a the line that begins with else, there's a pound symbol, which is how you start a comment in a Shell script. So everything after that symbol is "commented out" and is not read by the computer as commands to run. You need to start a new line beginning at echo "$hostline" so it looks like this:
else # If the line wasn't found, add it using an echo append >>
echo "$hostline" >> "$filename" # Let's recheck to be sure it was added.
grep -q "$needle" "$filename"
The if statement that follows it looks fine the way you've formatted it.
Also on Jamf Nation you can format your post so that a script is displayed in it's own block quote. When posting, click the >_ button next to the bold/italics buttons and the quotation button. Then you can paste your script in to help readability.
Posted on 11-07-2017 06:39 AM
Also, are you blocking touch.facebook.com on macOS devices? That looks like the Facebook's website for iOS.
Posted on 11-08-2017 10:05 AM
sorry, no dice.
Posted on 11-09-2017 08:43 AM
@athibault What happens when Jamf runs the script? Is there an error message?