BE_ExecuteSystemCommand ( command { ; timeout ; executeUsingShell } )

Performs a command line script of the command parameter. Essentially the same as using Terminal on the Mac, or CMD.exe on Windows.

Versions :
2.0.0 : Added.
4.0.6 : Switched to a different library, which broke a lot of things, and meant it could only run one command at a time.
4.1.3 : Do not crash when attempting to execute an empty command.  MacOS, Linux and iOS enable multiple calls to shell like version 4.0.5.
4.2.0 : Reverted back to the 4.0.5 and fixed the crash issue, and added executeUsingShell as an option.

Parameters :
command : the content of the command to run.
timeout ( optional ) : A value, in milliseconds that the plugin should wait for a result before returning. 
executeUsingShell ( optional, defaults to true )  : whether to execute the command directly or in a shell.

  • Using a timeout value of -1 will wait forever or until the command finishes.  This is also equivalent to passing the parameter with only the command and no timeout parameter.
  • A timeout value of 0 or and empty parameter "" will return to FileMaker immediately and will always return the error code 12000 - timeout exceeded.
  • Any other timeout value will wait a maximum of the time in milliseconds or when the command finishes, whichever is first.  This is the same as if the parameter was left out.
  • the executeUsingShell default is true, which means you can include multiple commands in a single command, like you would on unix.  Plus it has access to the shell environment variables etc.  Setting to false will require full paths, but can be more compatible.  Setting this to false is gets the same compatibility as the 4.0.6 through 4.1.4 versions.

Result : the result of the command or an error code if applicable. 

  • Results are usually via stdout.  Not all commands write to stdout, so if you need to get other output, you'll need to redirect that to a file, and then read it in separately.
  • Results are only up to the point of the timeout obviously.

A result of 12000 is a plugin error : Timeout exceeded.

Notes :

On the Mac this uses the "sh" shell, which is different from the default shell which is "bash". There can be syntax differences between commands using these shells, so if you find a difference between the two, first try running BE_ExecuteSystemCommand ( "/bin/bash -c \"commandhere\"" ) to see if that removes the difference.

You can also string multiple commands together in a single plugin function call by using Char ( 10 ) on Mac and Char ( 13 ) on Windows as command separators, but only when using executeUsingShell set to True/1.

Still need help? Contact Us Contact Us