Any AppleScript people out there that can help me figure out why the "open location" part of the script is failing to open to the URL?
This works:
osascript -e "tell application \\"$browser\\" to activate"
This does not work:
osascript -e "tell application \\"$browser\\" to activate open location "https://www.yahoo.com""
loggedInUser=$(echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ && ! /loginwindow/ {print $3}')
# identify default browser
defaultBrowser=$(plutil -p /Users/$loggedInUser/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist | grep 'https' -b3 |awk 'NR==3 {split($4, arr, "\\""); print arr[2]}')
if [ "$defaultBrowser" = "com.google.chrome" ]; then
browser="Google Chrome"
elif [ "$defaultBrowser" = "com.apple.safari" ]; then
browser="Safari"
elif [ "$defaultBrowser" = "org.mozilla.firefox" ]; then
browser="Firefox"
elif [ "$defaultBrowser" = "com.microsoft.edgemac" ]; then
browser="Microsoft Edge"
fi
echo "Script result: Browser = $browser"
osascript -e "tell application \\"$browser\\" to activate open location "https://www.yahoo.com""