executes some DOS instructions (Windows only)
bOK = dos(commands) [output, bOK] = dos(commands) [output, bOK, exitcode] = dos(commands) .. = dos(commands, '-echo')
Single text containing instructions sent to the MS Windows cmd.exe command interpreter.
Forces the display of results (Windows standard output and error message) in the Scilab console.
Single boolean: %T
if commands
has been executed without cmd.exe error, %F
otherwise.
Column of text: standard output and standard errors yielded by the MS Windows interpreter.
Integer exit code returned by cmd.exe after completion.
dos()
opens a new session of the MS Windows command interpreter
cmd.exe, sends the commands
to it,
lets it processing commands
instructions, receives the standard
output and possible error message yielded by the processing, and closes the interpreter
session.
The starting current working directory and environment variables of the cmd.exe session are set as described for host().
The standard output and error messages yielded by the OS interpreter are never displayed in the OS terminal running Scilab (the consolebox). They are managed in the following ways:
output
argument is expected, the standard output
and errors messages are returned in it as a column of text.'-echo'
option is used, the standard output and
errors messages are (in addition) displayed in the Scilab console.![]() |
Current working directory and environment variables in the cmd.exe session:
pwd() // in the Scilab session [r, ok] = dos("cd"); r // in the dos() session setenv TEST AAAA ; // in the Windows interpreter running the Scilab session [r,ok] = dos("echo %TEST%"); r // in the dos() session // Environment variables set in a dos() session are lost when dos() returns: dos("set TEST=BBBB") [r,ok] = dos("echo %TEST%"); r getenv TEST | ![]() | ![]() |
--> pwd() // in the Scilab session ans = C:\Scilab\tests --> [r, ok] = dos("cd"); r // in the dos() session r = C:\Scilab\tests --> setenv TEST AAAA ; // in the Windows interpreter running the Scilab session --> [r,ok] = dos("echo %TEST%"); r // in the dos() session r = AAAA --> // Environment variables set in a dos() session are lost when dos() returns: --> dos("set TEST=BBBB") ans = T --> [r,ok] = dos("echo %TEST%"); r r = AAAA --> getenv TEST ans = AAAA