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 of 2 people found this helpful
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>
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).
=> The Server says "OK" (seems to have executed successfully)
fmsadmin list clients -u xxx -p xxx > /Users/Shared/users.txt
=> 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.
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
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)
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
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.
Applescript example, you can with or without the "with administrator privileges" part...
do shell script "/path/to/shell/script" with administrator privileges
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.
do shell script "/Library/FileMaker\\ Server/Data/Scripts/test.sh"
echo eins > /Users/Shared/test.txt
=> trigger "Run_Test.scpt" by FMS => OK, file "test.txt" is generated.
do shell script "/Library/FileMaker\\ Server/Data/Scripts/test.sh" with administrator privileges
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