Back to Aurora Vision Library website

You are here: Start » Function Reference » All Functions » Process » AvsFilter_Execute_WaitForExit

AvsFilter_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: avs
Module: FoundationLite

Executes a system command, captures output and waits for completion.

Syntax

void avs::AvsFilter_Execute_WaitForExit
(
	const atl::File& inCommand,
	const atl::Array<atl::String>& inArguments,
	const atl::Directory& inWorkingDirectory,
	const atl::String& inEncoding,
	int& outReturnCode,
	atl::String& outResult,
	avl::ByteBuffer& outRawResult
)

Parameters

Name Type Default Description
Input value inCommand const File& System command to be executed.
Input value inArguments const Array<String>& Arguments for the command.
Input value inWorkingDirectory const Directory& \".\" Working directory in which the command will be executed.
Input value inEncoding const String& Expected encoding of command output.
Output value outReturnCode int& Return code of the executed command.
Output value outResult String& Captured text data.
Output value 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 AVL.

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