9 Replies Latest reply on Oct 14, 2016 5:00 AM by c.sedlmair

    FMS-Sceduled System-Script (.command) on OSX

    c.sedlmair

      Hello,

       

      i want to run a batch-file (*.command, running on terminal), triggered by FileMaker-Server, to disconnect all clients by night.

      My batch-file does its work, by double-klick, but not triggered by Server.

      On Server i receipt the error-message "Stopped by user", and no action is performed.

      Can anyone give me a example of a working file?

       

      my current file is:

       

      disconnect.command

      #!/bin/bash

      fmsadmin disconnect

       

      Best Regards,

      Christian

        • 1. Re: FMS-Sceduled System-Script (.command) on OSX
          wimdecorte

          Not sure that the ".command" is supported, can you try with ".sh" as the extension?

           

          Also make sure the chmod/chown the file so that fmserver of group fmsadmin is the owner and has execute privs.

          • 2. Re: FMS-Sceduled System-Script (.command) on OSX
            wimdecorte

            c.sedlmair wrote:

             

             

            fmsadmin disconnect

             

             

            That's not the correct or complete command.  You need to specify "client" and provide the confirmation and username and pw otherwise it will prompt you and your shell script does not handle that.

             

            fmsadmin disconnect client -y -u <admin console username> -p <admin console pw>

            2 of 2 people found this helpful
            • 3. Re: FMS-Sceduled System-Script (.command) on OSX
              c.sedlmair

              I tested a lot of types:

               

              "*.sh" made no difference to "*.command".

              With chmod i setted the file to "777". Since then i could execute manually, but not from server. May i forgot a option?

              On FMS i executed by several logins for executing system-files, one of them executed the file (the same, wich i were logged in at the desktop, works).

               

              test.command

              #!/bin/bash

              exit

              => The Server says "OK" (seems to have executed successfully)

               

              test.command

              #!/bin/bash

              fmsadmin list clients -u xxx -p xxx > /Users/Shared/users.txt

              exit

              => by executing manually (double-klick / Open with Terminal) => the result is delievered to the named file, OK

              => by executing by FMS => The Server returns the Error-Code "127". This seems to be a OSX / Linux-code, but i could not found, what it means.

              • 4. Re: FMS-Sceduled System-Script (.command) on OSX
                wimdecorte

                Just to confirm:

                - you have the script saved to the FMS scripts folder

                - you have set the owner of the script to fmserver/fmsadmin

                - the script shows up as an option when you create a script schedule in the FMS admin console?

                 

                Not sure if the fmserver account that runs FMS has the rights to write to /Users/Shared

                Try to have it output that fmserver owns like the docs folder that is inside the FMS folder structure

                • 5. Re: FMS-Sceduled System-Script (.command) on OSX
                  c.sedlmair

                  a) Yes, Script is in /Library/FileMaker\ Server/Data/Scripts/test.command

                  b) the File (a)) has the same owner as i log me in to the admin-console

                  c) Yes, because its in a), see Screenshot

                  => The last, currently result was "Script was stopped by user" (in German: "vom Benutzer abgebrochen") (see Screenshot)

                   

                  FMS-scriptscedule.png

                  • 6. Re: FMS-Sceduled System-Script (.command) on OSX
                    c.sedlmair

                    P.S.:

                    in the above mentioned test i setted the user for executing the script to the user which is the owner of the file (chmod).

                    => the result in FMS was, like mentioned: "Script was stopped by the user".

                     

                    Now i setted the user for executing the script to the default-user (see screenshot).

                    => the result was "Script-Error" => but, if i execute the script manually (by klick on the file), it works

                     

                    sceduler.png

                    • 7. Re: FMS-Sceduled System-Script (.command) on OSX
                      Mike Duncan

                      The easiest way that I have found to work around this issue is to create an applescript to launch the shell script for you. There are some complicated instructions for setting owner, changing mod right, but I have always had trouble with those. You applescript can be pretty simple, and seems to do an end run around permissions issues. It just needs to call your shell script, command file, whatever.

                       

                      Put the applescript in the scripts folder and call it from FMS scheduler instead. Hope this helps.

                       

                      Mike

                      • 8. Re: FMS-Sceduled System-Script (.command) on OSX
                        Mike Duncan

                        Applescript example, you can with or without the "with administrator privileges" part...

                         

                        do shell script "/path/to/shell/script" with administrator privileges

                        • 9. Re: FMS-Sceduled System-Script (.command) on OSX
                          c.sedlmair

                          Thank you Mike, on this way i could execute terminal - scripts.

                          Unfortunately, this step which i needed (fmsadmin...), furthermore not works.

                          On all my tests, this command worked without any problems by typing directly by typing into the Terminal, and also, within a .sh-File, manually executed, but not if i trigger the same file by AppleScript. On this, AppleScript returned Error 127, which was the same Error like was returned by FMS.

                           

                          this is strange.

                           

                           

                          TEST1:

                          -

                           

                          Run_Test.scpt

                          do shell script "/Library/FileMaker\\ Server/Data/Scripts/test.sh"

                          -

                          test.sh

                          #!/bin/bash

                          echo eins > /Users/Shared/test.txt

                          -

                          => trigger "Run_Test.scpt" by FMS => OK, file "test.txt" is generated.

                           

                           

                           

                          TEST2:

                           

                          -

                           

                          Run_Test.scpt

                          do shell script "/Library/FileMaker\\ Server/Data/Scripts/test.sh" with administrator privileges

                          -

                          test.sh

                          #!/bin/bash

                          fmsadmin list clients -u xxx -p xxx > /Users/Shared/users4.txt

                          -

                          => AppleScript: error "/Library/FileMaker Server/Data/Scripts/test.sh: line 2: fmsadmin: command not found" number 127