<< setenv | OS functions | username >> |
status = system(command) |
status = system(command, timeout) |
status = dos(command) |
status = unix(command) |
status = unix(commands) |
[status, output, duration] = system(command) |
[status, output, duration] = dos(command) |
[status, output, duration] = unix(command) |
[status, output, duration] = system(command, '-echo') |
[status, output, duration] = dos(command, '-echo') |
[status, output, duration] = unix(command, '-echo') |
[s, outputs, duration] = unix(commands) |
[s, outputs, duration] = unix(commands, timeouts) |
a string: command to execute in command shell.
a cell of string or a string array: commands to execute in command shell in parallel.
an integer value (scalar): kill process using timeout in seconds.
an integer value (scalar: applied to all commands or vector: one by command): kill process using timeout in seconds.
an integer value: exit code value of the command.
a string: output of the command.
integer value: duration (milliseconds).
an matrix of integer value: exit code value of the commands (same dimensions than commands).
a string array: output of the commands.
an matrix of integer value: duration of each execution (milliseconds).
system sends a string to the operating system for execution. Standard output and standard errors of the shell command are written in the calling shell.
[status, output] = system(command, '-echo') forces the output to the Command Window, even though it is also being assigned into a variable.
Callback functions cannot be called until system command is not finished.
Nelson will convert characters to the encoding that your operating system shell accepts (ANSI on Windows by default, UTF-8 on others systems).
command can be interrupted with CTRL-C key, in this case status code returned will be 258 (WAIT_TIMEOUT) on Windows and 134 on others platforms (128 + SIGABRT)output contains 'ABORTED'.
if timeout value is 0. timeout disabled.
[s,w] = system('dir');
[s,w] = system('dir','-echo');
[s,w] = system(["echo hello", "dir", "echo world"])
tic();[s, w, d] = system(["PING -n 5 127.0.0.1>nul", "PING -n 7 127.0.0.1>nul", "PING -n 10 127.0.0.1>nul"]), toc()
tic();[s, w, d] = system(["PING -n 5 127.0.0.1>nul", "PING -n 7 127.0.0.1>nul", "PING -n 10 127.0.0.1>nul"], [1, 5, 3]), toc()
To detach an system command, include the trailing character, &, in the command argument.
[s,w] = system('notepad &');
Version | Description |
---|---|
1.0.0 | initial version |
Allan CORNET