dos
Execute DOS command and return output
For platform-independent code, use the system
command.
Description
Examples
Display Operating System Command Status and Output
Display the current folder using the cd
command. A
status
of zero indicates that the command
completed successfully. MATLAB® returns a character vector containing the current folder
in cmdout
.
command = 'cd';
[status,cmdout] = dos(command)
Input Arguments
command
— Operating system command
string | character vector
Operating system command, specified as a string or a character vector. The command can be a Windows® UI program that opens a user interface, or a DOS console command that you typically run in a DOS command window. The command executes in a DOS shell, which might not be the shell from which you started MATLAB.
Example: 'dir'
Output Arguments
status
— Command exit status
0 | nonzero integer
Command exit status, returned as either 0
or
a nonzero integer. When the command is successful, status
is 0
.
Otherwise, status
is a nonzero integer.
If
command
includes the ampersand character (&
), thenstatus
is the exit status whencommand
startsIf
command
does not include the ampersand character (&
), thenstatus
is the exit status uponcommand
completion.
cmdout
— Output of operating system command
character vector
Output of the operating system command, returned as a character vector. The system shell might not properly represent non-Unicode® characters.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™. (since R2024b)
Usage notes and limitations:
The
-echo
flag must be compile constant.stdin
of the calling process is inherited on Windows and UNIX®.On UNIX, if a second output is requested,
stdout
is redirected to a pipe. Otherwise,stdout
is inherited from the calling process.On Windows, the
nargout
determines whether the output read from the pipe is stored in a variable or sent tostdout
of the calling process. If the number of arguments is 1, the output from the pipe is sent tostdout
. Otherwise, it is stored in a variable.
Version History
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)