This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

dos

Execute DOS command and return output

For platform-independent code, use the system command.

Syntax

[status,cmdout] = dos(command)

Description

example

[status,cmdout] = dos(command) calls the operating system to execute the specified command and returns the output of the DOS command to cmdout.

For more examples, tips, and information about limitations, see system.

Examples

collapse all

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

collapse all

MS-DOS 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

collapse all

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 (&), then status is the exit status when command starts

  • If command does not include the ampersand character (&), then status is the exit status upon command completion.

Output of the operating system command, returned as a character vector. The system shell might not properly represent non-Unicode® characters.

Introduced before R2006a