King110
King110

Reputation: 122

Redirect MATLAB standard output for system command

I am running a test.bat file using the following code in MATLAB.

system('C:\Windows\system32\cmd.exe /K "test.bat"');

I don't want the output to be shown in MTLAB console.Also how can I redirect it's output to a file without using diary?

Upvotes: 1

Views: 450

Answers (1)

Eugene Sh.
Eugene Sh.

Reputation: 18381

Either you can embed the redirection into the command line:

system('C:\Windows\system32\cmd.exe /K "test.bat" > out.txt');

or store the result into variable:

[status, result] = system('C:\Windows\system32\cmd.exe /K "test.bat" );

And then fprintf the result to file.

Upvotes: 3

Related Questions