executes a Windows, Linux, or MacOS command
alias de host()
[status, stdout, stderr] = host(commands, echo=%f)
Single string containing instructions sent to the OS command interpreter.
Optional boolean used to print both stdout and stderr in Scilab's console.
Integer, the status code return by the executed command.
String that contains the standard output of the executed command. When the function is called with two output argument, stdout will contain both stdout and stderr.
String that contains the standard error of the executed command.
host(…)
creates a session of the OS command interpreter (sh
on Linux and MacOS, or cmd.exe on Windows),
to execute the given command.
host(…) returns both outputs in the same variable when it has been called with two output arguments.
It can be useful to maintain the chronological order of logs between stdout and stderr.
By using the optional argument echo=%t, the standard output and error will be printed in Scilab's console during the command execution.
![]() | The opened session of the OS interpreter is a fork of the session homing the current
Scilab session. As a consequence, it has the following properties:
|
// Detach a command to avoid waiting for its end if getos() == "Windows" then host("start /b ping localhost") else host("ping -c 3 localhost &") end // But, this command will wait for outputs if getos() == "Windows" then [stat, stdout] = host("start /b ping localhost") else [stat, stdout] = host("ping -c 3 localhost &") end | ![]() | ![]() |
if getos() == "Windows" then host("ping localhost", echo=%t) else host("ping -c 3 localhost", echo=%t) end | ![]() | ![]() |
| Version | Description |
| 2025.1.0 | Returns standard output and standard error. |
| 2026.0.0 | An optional named argument 'echo' was added. |