system
Executes the shell command stringCommand. If executed in 'sync' mode or without additional inputs, the application waits until the execution is complete. If executed in 'async' mode, stringCommand is executed in a detached thread and control is returned to the application immediately.
Syntax
R1 =system(stringCommand)
[R1, R2] = system(stringCommand)
[R1, R2] = system(stringCommand, getoutput)
R1 = system(stringCommand, mode)
[R1, R2] = system(stringCommand, getoutput, mode)
Inputs
- stringCommand
- Command to be executed in the operating system shell.
- getoutput (optional)
- If true, returns the output if mode is 'sync'. The default value is false.
- mode (optional)
- Controls how stringCommand is executed. If the value of mode is 'async', the system command is executed in asynchronous mode and the output is not returned. If the value of mode is 'sync', the system command is executed in synchronous mode, where the application waits until the stringCommand is terminated. The default value is 'sync'.
Outputs
- R1
- The status of the system command executed. The process ID of the executed stringCommand is returned if the mode is 'async' .
- R2 (optional)
- Contains any text echoed to standard output when the system command is executed.
Examples
R = system('echo %date% %time%')
R = 0
[R1, R2] = system('echo %date% %time%')
R1 = 0
R2 = Fri 02/09/2018 12:24:58.52
[R1, R2] = system('echo %date% %time%', true, 'sync')
R1 = 0
R2 = Fri 02/09/2018 12:24:58.52
R1 = system('notepad.exe', 'async')
R1 = 18300