4 Replies Latest reply on Oct 30, 2012 8:23 PM by Abhi_apple

    How to run an applescript through terminal

    Abhi_apple Level 1

      Hi Friends,

       

      I have a indesign script done in AppleScripting.

       

      I want to run this in a terminal window. Any ideas what is the correct syntax of running an apple-script through a terminal window.

       

      I tried using the below sample script in terminal by using osascript. (Not sure if this is the correct representation)

       

      osascript script_name.scpt.

       

      But, it returns an error (shown as below)

       

      2012-10-30 11:34:43.667 osascript[2388:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find:

                /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper

      osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

      2012-10-30 11:34:43.669 osascript[2388:903] Error loading /Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScript ingAdditions:  dlopen(/Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QX PScriptingAdditions, 262): no suitable image found.  Did find:

                /Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPS criptingAdditions: mach-o, but wrong architecture

      osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/QXPScriptingAdditions.osax" declares no loadable handlers.

      script_name.scpt: execution error: No user interaction allowed. (-1713)

       

       

      Thanks for your help!

       

      Regards,

       

      Abhishek

        • 1. Re: How to run an applescript through terminal
          -hans- Level 4

          Hi,

           

          try to run your script from a starterScript:

           

           --comment: guess my source is been macscripter here; don't know anymore ...
          --don't change anything in this script !!
          on run {sourcefile}
              tell application "AppleScript Runner"
                  do script sourcefile
              end tell
          end run
          

           

          save as app

           

          execute your script with this terminalCommand:

           

          osascript pathToRunnerscript pathToYourscript
          

           

          Hope it'll work

           

          Hans-Gerd Claßen

          1 person found this helpful
          • 2. Re: How to run an applescript through terminal
            Abhi_apple Level 1

            Hi,

             

            Thanks for your response..I will check it.

             

            On a slighter note, please can you let me know what is a starterScript and what does the below script actually does..

             

            I am new to apple scripting and it will help me to understand the concepts.

             

             

            --comment: guess my source is been macscripter here; don't know anymore ...

            --don't change anything in this script !!

            on run {sourcefile}

            tell application "AppleScript Runner"

            do script sourcefile

            end tell end run

             

             

            Thanks for your help!

             

            Thanks,

             

            Abhishek

            • 3. Re: How to run an applescript through terminal
              -hans- Level 4

              Hi,

               

              I don't know why you want to run AS via Terminal, perhaps it is not necessary ... keep this in mind.

               

              the 'starterScript' simply runs your Script via APP 'AppleSript Runner'.

              'command osascript + the starterScript +  your script as input for the starterscript'

               

              I guess you've got a display dialog outside of tellblock, which causes the Error. osascript can't target a process for this.

               

              Another approach could be to save your script as app and run it in Terminal via 'open pathToYourScript'

               

              Hans-Gerd Claßen

              • 4. Re: How to run an applescript through terminal
                Abhi_apple Level 1

                Thanks for your note.

                 

                It is helpful.

                 

                Abhishek