9 Replies Latest reply on May 23, 2012 8:32 PM by databuzz

    Writing to a log from a server scheduled script

    ericellis9

      Hi there...

       

      I am trying to track down a problem with a script I am running from the server. In an attempt to try to determine where the problem is, I have created another script that writes a record to a log table. In this way, I thought I would be able to track down the problem within the script.

       

      However, the script that writes the log file does not seem to work when it is trigered by a server script. If I run the same proces from the client, the script works fine.

       

      Any ideas on why this would be the case?

       

      Thanks!

       

      Eric

        • 1. Re: Writing to a log from a server scheduled script
          BowdenData

          I am trying to track down a problem with a script I am running from the server.  In an attempt to try to determine where the problem is, I have created another script that writes a record to a log table.  In this way, I thought I would be able to track down the problem within the script.

           

          However, the script that writes the log file does not seem to work when it is trigered by a server script.  If I run the same proces from the client, the script works fine.

           

          Eric

           

          Eric,

           

          In the bottom, left of the edit script window, make sure to select "server" in the show compatibility menu. This will show you what commands are compatible or not. The other place to look for info is in the Server Events log in the FMS console. It shows entries about when a server-side task starts, errors it encounters and so forth. Depending on whether you have Allow User Abort = OFF/ON  in your script will determine if it stops on an error or not. Set it to OFF if you want it to continue processing.

           

          You are on the correct path in my opinion about doing your own logging. I assume for this that you have just created a "log" table in your dB file. In your main script that you are trying to debug, just insert steps to write a record to the log table. You could also have the log table just contain one record with one text field and write data to that one field. Just apply the new text to the existing contents for each "entry".

           

          HTH.

           

          Doug de Stwolinska

          1 of 1 people found this helpful
          • 2. Re: Writing to a log from a server scheduled script
            oditech

            Eric,

             

            You can also schedule a script sequence in FileMaker Server. I do this to run a batch file (windows) or shell script (Mac) to append a log file after scripts run. Works like a charm!

            1 of 1 people found this helpful
            • 3. Re: Writing to a log from a server scheduled script
              CarlHenshall

              Hi Eric

               

              Take a look at this:

              http://honza.24usoftware.com/debugging-scripts-by-writing-to-event-log

               

              Basically you write to the FileMaker log by putting the relogin step into your script wherever you want something logged.  You put whatever message you want to appear in the log into the account name & FMS will register the "error" in it's log and give you the account name that failed to log in.

               

              I used this just yesterday to see which parts of a server script took a long time.

               

              Best regards

              Carl

              • 4. Re: Writing to a log from a server scheduled script
                ericellis9

                Thanks Doug!  Those were great ideas - I forgot there was a "Server" option under the show compatibility pulldown.

                 

                Unfortunately, I was not using any invalid scroipt steps and the Allow User Abort option was set to "Off".  I was trying to write to a log table - however, it was in another DB (I am trying to seperate the data from the interface).  Do you think that could be the problem?  I'm still baffled on why the script writres to the log table when it is run from the client but not from the server.

                 

                Eric

                • 5. Re: Writing to a log from a server scheduled script
                  ericellis9

                  Hi ODI (I use you guys for one of my DB hosting).

                   

                  Anyway, thanks for the response.  When you say "script sequence", do you mean a script schedule? 

                   

                  Also, when you say "append a log file", can you tell me a little more about that?

                   

                  Thanks...


                  Eric

                  • 6. Re: Writing to a log from a server scheduled script
                    ch0c0halic

                    Eric may have gone out-of-bounds,

                     

                    Is the log table in a file on the same FMS? FMS is not a client and cannot connect to a file located on a different FMS.

                    • 7. Re: Writing to a log from a server scheduled script
                      databuzz

                      Hi Eric,

                       

                      Is the file containing the log table in the same folder on the FM Server as the file you're running the server side script in?

                       

                      You might have to add an additional file reference if that is the case using the relative path format, e.g.:

                       

                      file:contacts

                      file:../OtherFolder/logFile

                       

                      Andrew

                      • 8. Re: Writing to a log from a server scheduled script
                        ericellis9

                        Hi Andrew...

                         

                        Thanks for your response.  I think you might have pointed out the problem.  My DB's are in different folders.  I think I will just combine them into one folder, thus avoiding any potentil path issues.

                         

                        If the DB's are in the same folder, and I am accessing a table in a diffferent DB, do I have to do anything special?

                         

                        Thanks again...

                         

                        Eric

                        • 9. Re: Writing to a log from a server scheduled script
                          databuzz

                          Hi Eric,

                           

                          If all the db's are in the same folder then everything should "just work" as far as the server side script is concerned.

                           

                          Make sure that you don't inadvertantly break any existing file references from other files to the file you're planning to move.

                           

                          Andrew