I'm trying to create a script .sh
to capture the action of a dialog on Mac that shows the buttons No
and Si
then execute code depending on the response, I have not been able to get it to take the user's actions.
This is what I have achieved:
#!/bin/sh
#!/usr/bin/env bash
# error "Message"
function advertencia() {
osascript <<EOT
tell app "System Events"
display dialog "$1" buttons {"No","Si"} default button 2 with icon caution with title "$(basename $0)"
return result
end tell
EOT
}
resultado=$(advertencia "Selecciona una opcion:")
if ["$resultado" == "Si"]; then
advertencia "Seleccionaste Si"
else
advertencia "Seleccionaste no"
fi
But it does not work.
I found this way to do it and it worked for me: