dos - Execute DOS command and return output - MATLAB (original) (raw)
Main Content
Execute DOS command and return output
For platform-independent code, use the system command.
Syntax
Description
[[status](#btf8jkj%5Fsep%5Fshared-status),[cmdout](#btf8jkj%5Fsep%5Fshared-cmdout)] = dos([command](#btf8jkj-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
Display the current folder using the cd
command. Astatus
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
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
Output of the operating system command, returned as a character vector. The system shell might not properly represent non-Unicode® characters.
Extended Capabilities
Usage notes and limitations:
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