Search code examples
macosshellapplescriptautomator

How to pass value from apple script to shell script in Automator?


I'm planning to run a shell script followed by a AppleScript. But I would like to know if it is possible to pass a parameter value to shell script as follows.

enter image description here

I'm getting some weird error which I do not understand. Can someone please help me understand the error and provide a way to pass value (Continue/Don't Continue) to Shell script from Apple Script?

Code in Text format:

on run {input, parameters}

   set theDialogText to "By running this script, it will update your hosts file. Would you like to continue?"

   set isupdate to display dialog theDialogText buttons {"Don't Continue", "Continue"} default button "Continue" cancel button "Don't Continue"

return {isupdate}

end run


Solution

  • First of all please post text, not an image.

    The error occurs because display dialog returns a record (in terms of Objective-C a dictionary) but the parameter must be a string.

    You have to write

    set isUpdate to button returned of (display dialog ... )