1 2 Previous Next 22 Replies Latest reply on Apr 10, 2014 6:32 AM by APIcoder

    Applescript Shell Script

    bigtom

      This Applescript works for a bit then it starts giving an error of Object not found.

       

      If I replace the variable for the path with a static one it works fine. However this is not possible outside of testing. It seems to work great when opened by the client directly as a local file. When running on Server it has problems, but only after a little while. Had the issue with this same test file. The folder is present and the file is present at the time the script is called. Ran the script debugger and watched the data viewer. Everything seems to point to the AS having a problem with the path, but ony sometimes...?

       

      The problem seems to be with the path for the shell script.

       

      This is making me crazy. Advice is appreciated.

        • 1. Re: Applescript Shell Script
          BruceRobertson

          Don't forget "quoted form of", the applescript method of escaping strings:

           

          set myPath to cell "image_sample::path" of current record

          set myPath to quoted form of myPath

          set myScript to "sips -s format jpeg -s formatOptions normal " & myPath

          do shell script myScript

          • 2. Re: Applescript Shell Script
            sporobolus

            on 2014-04-09 1:06 bigtom wrote

            This Applescript works for a bit then it starts giving an error of Object not found.

             

            as Bruce suggest, "quoted form" is a way to protect against special characters

            in the path, such as if the user's folder name or the SKU has a space, but that

            doesn't give "object not found" in my tests, so i wonder if there's another issue

             

            AppleScripts in FileMaker run asynchronously, so i wonder if the sips command

            isn't finished at the point your next FileMaker script steps pick up

            • 3. Re: Applescript Shell Script
              bigtom

              I had tried with "quoted form of" and had the same issue. Put it back in there and still same issue.

               

              I added a 2 second pause before and after the applescript to ensure the export had plenty of time to wite the file and the apple script had time to do the resample. Still same problem.

              • 4. Re: Applescript Shell Script
                APIcoder

                You were almost there, I added: tell application "FileMaker Pro Advanced"

                 

                 

                tell application "FileMaker Pro Advanced"

                          tell layout "image_sample" of window "image_sample"

                                    set myPath to cell "image_sample::path" of current record

                                    set myScript to "sips -s format jpeg -s formatOptions normal " & myPath

                          end tell

                end tell

                do shell script myScript

                 

                 

                 

                 

                 

                I may not understand the script ImageDist1, but your script runs in an infinite loop.

                • 5. Re: Applescript Shell Script
                  bigtom

                  I am not seeing the infinite loop. How would I distinguish Filemaker Pro clients from Advanceed clients?

                  • 6. Re: Applescript Shell Script
                    sporobolus

                    on 2014-04-09 16:56 APIcoder wrote

                    You were almost there, I added: tell application "FileMaker Pro Advanced"

                     

                    you don't need that on a script that runs from within FileMaker

                     

                     

                    I may not understand the script ImageDist1, but your script runs in an infinite loop.

                     

                    it runs from on OnModified trigger from the thumbnail field

                    • 7. Re: Applescript Shell Script
                      bigtom

                      So when the final image is set in the field it is modified and the script runs again. That makes sense, but when it does work the script does not loop so far as I can tell.

                      • 8. Re: Applescript Shell Script
                        APIcoder

                        After Perform AppleScript:

                        The script calls Go To Field [image_sample :: thumb]

                        Field image_sample :: thumb has a Script Trigger "ImageDist1"

                         

                        You're right, It works

                        • 9. Re: Applescript Shell Script
                          bigtom

                          Im not getting the loop. Used your exact script recommend in the test file and it has been working so far no loop.

                           

                          Tried this in a test of the actual solution file and still not working. Same 1728 error. When adding the Tell Filemaker line the error says Filemaker Pro Advanced had an error. Maybe the problem is File maker not assigning the path to the variable properly.

                          • 10. Re: Applescript Shell Script
                            bigtom

                            Just to clear up something.

                             

                            tell layout "layout name" of window "name in the window header"

                             

                            The name has the name of the server in parenthesis. Is that needed in the window name?

                            • 11. Re: Applescript Shell Script
                              bigtom

                              Does not seem to make a difference about the window name.

                               

                              I am just trying to see find the difference between the sample file that is working and the actual soluiton that needs the script.

                              • 12. Re: Applescript Shell Script
                                BruceRobertson

                                Whether or not "quoted form of" solved this problem; that IS how you should pass path strings to shell scripts and you should continue using it so you are sure you are not introducing path problems if for instance your new file name or path includes a space.

                                • 13. Re: Applescript Shell Script
                                  bigtom

                                  Bruce I get it and I will use it that way in the future. That does not seem to be my problem directly though.

                                  • 14. Re: Applescript Shell Script
                                    bigtom

                                    I think I found the loop. Client started crashing everytime the script is run. Working on that now.

                                     

                                    I appreciate the insight from everyone.

                                    1 2 Previous Next