【问题标题】:Run multiple external commands at once in Octave在 Octave 中一次运行多个外部命令
【发布时间】:2017-01-27 08:46:37
【问题描述】:

我正在尝试打开多个 cygwin 终端并通过 octave GUI 在每个终端中运行一个 .exe 文件。我能够在 MATLAB 中做到这一点,但在 octave 中完全相同的代码不起作用。 使用的代码:

dos(['C:\cygwin64\bin\mintty.exe /bin/bash -login ./testtorun_ig1_1.sh']);
dos(['C:\cygwin64\bin\mintty.exe /bin/bash -login ./testtorun_ig1_2.sh']);
dos(['C:\cygwin64\bin\mintty.exe /bin/bash -login ./testtorun_ig1_3.sh']);
dos(['C:\cygwin64\bin\mintty.exe /bin/bash -login ./testtorun_ig1_4.sh']);

testtorun_ig1_1 有打开 .exe 文件的命令。

在 octave 中发生的情况是,最初打开一个 cygwin 终端并运行 .exe 文件。应用程序完成并退出后,cygwin 终端关闭并打开下一个 cygwin 终端打开并运行第二个 .exe 文件。我希望能够一次运行 4 个 cygwin 终端,这是在 MATLAB 中发生的,但不是在 octave 中发生的

【问题讨论】:

  • 你可以直接在cygwin上install Octave

标签: matlab cygwin octave


【解决方案1】:

在 Octave 中,dos 会等待外部命令完成,然后再执行任何其他命令。

Octave 等待外部命令完成,然后在 status 中返回程序的退出状态,并在 text 中返回任何输出。

如果您想异步评估外部命令,您应该使用带有'async' 输入参数的system 命令

id = system('C:\cygwin64\bin\mintty.exe /bin/bash -login ./testtorun_ig1_1.sh', 0, 'async')

【讨论】:

  • 用“&”附加代码似乎不起作用,使用带有“异步”的系统。
  • 奇怪的是,在 MATLAB 中 system waits or otherwise 取决于命令
猜你喜欢
  • 2022-11-02
  • 2022-12-04
  • 2013-05-27
  • 2018-06-27
  • 1970-01-01
  • 2011-10-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多