フィルターのクリア

prlctl: take input from script instead of command window

2 ビュー (過去 30 日間)
Jacqueline
Jacqueline 2018 年 5 月 21 日
コメント済み: Walter Roberson 2018 年 5 月 21 日
I would like to automate the following sequence: enter a parallels VM, run executable, exit VM, check results using MATLAB, adjust settings, then re-enter and re-run executable until I get a certain result.
I am running a system command to enter the VM's terminal. Once I do this I would like to continue with the next line of code to be entered into the VM terminal.
For example, I would like to enter, run a command, then exit. Trying this:
!prlctl enter VM
dir
exit
MATLAB is busy after the first line, waiting for input from MATLAB's command window. I can type dir then exit on the command window and it works as expected, but how do I automate it so the the next line of input to the VM is coded instead of taken from MATLAB's command window?

採用された回答

Walter Roberson
Walter Roberson 2018 年 5 月 21 日
編集済み: Walter Roberson 2018 年 5 月 21 日
Write the text into a file, and use I/O redirection.
tname = tempname();
fid = fopen(tname, 'wt');
fprintf(fid, 'dir\nexit\n');
fclose(fid);
cmd = sprintf('prlctl enter VM < "%s"', tname);
[status, message] = system(cmd);
  2 件のコメント
Jacqueline
Jacqueline 2018 年 5 月 21 日
Perfect. Thank you!
Walter Roberson
Walter Roberson 2018 年 5 月 21 日
Oh yes, and remember to delete the file afterwards. You might want to use onCleanup() for that.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by