You are here: Start » Function Reference » All Functions » Process » FisFilter_Execute_WaitForExit
This is Filter Equivalent. This function may be present in generated code, but should not be used in hand-written code.
Header: | STD.h |
---|---|
Namespace: | fis |
Module: | FoundationLite |
Executes a system command, captures output and waits for completion.
Syntax
void fis::FisFilter_Execute_WaitForExit ( const ftl::File& inCommand, const ftl::Array<ftl::String>& inArguments, const ftl::Directory& inWorkingDirectory, const ftl::String& inEncoding, int& outReturnCode, ftl::String& outResult, fil::ByteBuffer& outRawResult )
Parameters
Name | Type | Default | Description | |
---|---|---|---|---|
![]() |
inCommand | const File& | System command to be executed. | |
![]() |
inArguments | const Array<String>& | Arguments for the command. | |
![]() |
inWorkingDirectory | const Directory& | \".\" | Working directory in which the command will be executed. |
![]() |
inEncoding | const String& | Expected encoding of command output. | |
![]() |
outReturnCode | int& | Return code of the executed command. | |
![]() |
outResult | String& | Captured text data. | |
![]() |
outRawResult | ByteBuffer& | Captured raw bytes. |
Description
Filter executes a command provided in inCommand with inArguments arguments. The command will be executed in a directory provided in inWorkingDirectory.
Output outResult contains text captured during execution of the command.
Usually value 0 on output outReturnCode means that command was executed correctly.
Program execution is blocked until command execution is finished.
inEncoding input determines which encoding will be used for reading output text:
- UTF8 - UTF8
- UTF16 - UTF16, little endian
- OEM - current DOS code page (for example 850)
- ANSI - current Windows code page (for example 1252)
- CP + number - specific code page, for example CP1250
- RAW - skips text conversion, outResult will be empty. User can provide their own conversion using outRawResult.
Note that code pages are supported on Windows only.
Examples
How to get name of the current user:
- Set inCommand to C:\Windows\System32\cmd.exe.
- Add argument /c whoami to inArguments.
- User name will be provided on outResult output.
Remarks
Usage of this filter is not recommended in FIL.
On Windows both standard output and standard error streams are redirected. On Linux only standard output is redirected.
Errors
If an error occurred during the process execution a value -1 will be returned on outReturnCode.
List of possible exceptions:
Error type | Description |
---|---|
DomainError | Encoding not supported on Linux: provided encoding |