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)
[R1...] = system(stringCommand, getoutput, 'async', 'threadaffinity', nprocs)
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'.
- 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.
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
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 OpenMatrix. To do this, append "set ALTAIR_HOME=&" to the string command to be executed in the system function.
"C:/Program Files/Altair/2021/hwsolvers/scripts/motionsolve.bat" solverdeck.xml
system('set ALTAIR_HOME=&"C:/Program Files/Altair/2021/hwsolvers/scripts/motionsolve.bat" solverdeck.xml');