BE_ExecuteSystemCommand ( command { ; timeout } )

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.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.

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. Using a value of -1 will wait forever, until the command finishes. A value of 0 will return to FileMaker immediately, and any other value will wait a maximum of the time in milliseconds or when the command finishes, whichever is first.

Result : the result of the command ( via stdout, if you need to get other output, you'll need to redirect that to a file), if any, up to the point of the timeout. Function calls that have a timeout of 0 will not return any result ( obviously ), and will throw a timeout error - that is expected behaviour.

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

Notes :

On Windows you need to prefix your command with "cmd.exe /c". For example "cmd.exe /c dir" will list the directory contents. No prefix is required for Mac.

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.

Still need help? Contact Us Contact Us