5 Replies Latest reply on Jan 16, 2014 2:05 PM by jmw

    Calculated AppleScript Madness

    ericdano

      Title

      Calculated AppleScript Madness

      Post

           I'm trying to get a shell script to run from FileMaker. Well, not a shell script, a Python script.

           Here is what I'm trying, and it doesn't work. I know the script works just fine.

           This is a Calculated AppleScript,

           "tell application \"Finder\"¶do shell script \"python ~/Scripts/PDFMerge.py " & Students::First Name  &  Students::Last Name & "\" ¶end tell"

           If I take out Either Students::First Name OR Students::Last Name the script runs fine. Some how Filemaker isn't passing BOTH values to the script?

           Thanks!

       

        • 1. Re: Calculated AppleScript Madness
          jmw

               I do not not think that that is the problem as I have done similar AppleScripts which work fine. I suggest to put the calculation result in a variable so you can check the syntax, especially where quotes and whitespaces are concerned. You can then also test the script outside of FileMaker to see if that runs ok.

               Could it be that the resulting name requires quotes as it will be multiple words (I guess that there should be a whitespace in between first and last name although the calculation does not put one there), and as long as you have just either first or last name the resulting string is just one word? 

          • 2. Re: Calculated AppleScript Madness
            Jade

                 Your quotation marks do not balance.

                 Try:

                 "tell application \"Finder\"" & ¶ & "do shell script \"python ~/Scripts/PDFMerge.py \"" & Students::First Name  &  Students::Last Name & ¶ & "end tell"

            • 3. Re: Calculated AppleScript Madness
              ericdano

                   That doesn't work at all. Filemaker gives me a

                   "Expected end of line but found identifier" error -2741

                    

               

              • 4. Re: Calculated AppleScript Madness
                ericdano

                     I don't think it is Whitespace problems, if I create a variable, like $NameString or $$NameString, and do a display dialog, it looks right. 

                     It is totally strange it will run fine with ONE of the fields, like first name, but not the second field.

                 

                • 5. Re: Calculated AppleScript Madness
                  jmw

                       Ok, it looks right. Does it execute correctly also from within AppleScript Editor?