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.
Type: string
getoutput (optional)
If true, returns the output if mode is 'sync'. The default value is false.
Type: Boolean
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'.
Type: string
nprocs (optional)
Controls how stringCommand is executed with the async mode on Linux. If the value of nprocs is 'max', the system command is executed in asynchronous mode with equal thread affinity on all available cores. If the value of nprocs is 'default', the system command is executed in asynchronous mode, with the Linux system deciding upon which core the command will be run. The default value is 'default'. On Windows, this option has no effect.
Type: string

Outputs

R1
The status of the system command executed. The process ID of the executed stringCommand is returned if the mode is 'async'.
Type: integer
R2 (optional)
Contains any text echoed to standard output when the system command is executed.
Type: string

Examples

Run the system command, without retrieving the output:
R = system('echo %date% %time%')
R = 0
Run the system command, with the text displayed to standard output:
[R1, R2] = system('echo %date% %time%')
R1 = 0
R2 = Fri 02/09/2018 12:24:58.52
Run the system command, retrieving the output:
[R1, R2] = system('echo %date% %time%', true, 'sync')
R1 = 0
R2 = Fri 02/09/2018 12:24:58.52
Run the system command, asynchronously:
R1 = system('notepad.exe', 'async')
R1 = 18300
Run the system command asynchronously on Linux, specifying the system to use all available cores:
system('mdl_batch test.mdl test.xml MotionSolve', 'async', 'threadaffinity', 'max');

Comments

It is necessary to set the ALTAIR_HOME variable to empty before calling any Altair product from inside Activate. To do this, append "set ALTAIR_HOME=&" to the string command to be executed in the system function.

For example, default call of MotionSolve in the command shell:
"C:/Program Files/Altair/2021/hwsolvers/scripts/motionsolve.bat" solverdeck.xml
Same call of MotionSolve through the Activate system function:
system('set ALTAIR_HOME=&"C:/Program Files/Altair/2021/hwsolvers/scripts/motionsolve.bat" solverdeck.xml');