Execute Shell (script step reference)

By May 1, 2017 May 22nd, 2019 Online Help, Troi File Plug-in
Troi File Plug-in for FileMaker Pro

Execute Shell

Execute a command in the (UNIX or Windows) shell of the operating system.

SyntaxScript step badge

Execute Shell [ Select ; Result ; Shell command ; Timeout ; Wait on result ;
                Encoding ; Wait time after exit ; Show command window ]

Options

Select entire contentsreplaces the contents of a field with the result. If not checked the result replaces the currently selected portion of the field
Resultthe result of the shell command or an error code
Shell commandthe command to be executed
Timeoutspecify the timeout time in seconds (default = 20 seconds)
Wait on resultuncheck to execute the shell command without waiting on a result
Encodingthe desired character encoding, like UTF-8
Wait time after exit(Windows only) wait the specified seconds after the command finishes
Show command window(Windows only) show the command window when the shell is running

Returned Result

Data type returned

Text

Result

The result of the shell command or an error code

If an error occurs it will start with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:

$$-4218kErrCanNotEnablecan not start a shell
$$-4230kErrTimeouttimeout error

Other errors may be returned.

Originated in

Troi File Plug-in 9.0

Compatibility

FileMaker Pro 16 to 18

Considerations

This is a powerful step, with which you can accomplish multiple commands. Please read about the shell command in Unix or Windows before using this.

For Windows: to be able to use spaces and quotes in the command wrap the whole command in 2 extra double quotes, one at the beginning and one at the end, like “”C:\testapp.exe” “test param””

(Windows) If you choose UTF8 Encoding the plug-in indicates invalid UTF-8 characters with the string <INVALID UTF8>.

Example

On Windows:

Execute Shell [ Select ; gResult ; "dir C:\"  ]

On Mac OS:

Execute Shell [ Select ; gResult  ; "ls /" ]

This will list the contents of the root folder.

Example 2

On Windows:

Execute Shell  [ Select ; gResult ;  "echo testtext > C:\example.txt" ;  Timeout: 5  ]

On Mac OS:

Execute Shell  [ Select ; gResult ; "echo testtext > /example.txt" ;  Timeout: 5  ]

This will create a text file example.txt on your startup disk. If the command takes more time than 5 seconds the plug-in will return with a timeout error $$-4230.

Related functionFunction badge

TrFile_ExecuteShell

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 14 to 18 –> Execute Shell (filep7295) 2019-0522 16:36:06