dos
Runs a command through the Windows command interpreter and returns its status and output.
Category: Environment and Settings > System Commands
Syntax
status = dos(cmd)
Runs cmd, showing its output, and returns the exit status.
[status, out] = dos(cmd)
Captures the output in out instead of showing it.
Description
dos is the Windows-specific form of system. The command string goes to the Windows shell, so built-in commands like echo and dir work. Without an output argument the text is printed; with one, it is returned as a character vector.
Input arguments
cmd- Command line to run.
Output arguments
status- Exit code of the command;
0means success. out- Text the command wrote as output.
Example
Capture the output
[status, out] = dos('echo hi');
disp(status)
disp(strtrim(out))
Output
0
hi
Notes
In MATLAB, dos is meant for Windows. Prefer system in code that must also run on other platforms.