MATLAB命令(从庆典/命令行)在一个已经运行的会话 [英] matlab command (from bash / command line) on an already running session
问题描述
$ matlab -nodesktop -nojvm &
我怎么会在刚刚创建的会话中执行命令MATLAB?
How would I execute matlab commands on the session that was just created?
在换句话说,我想在后台运行一个MATLAB会话,并在任何时间任意终端,而无需创建一个新的会话中执行MATLAB命令和/或脚本。
In other words, I want to have a matlab session running in the background, and execute matlab commands and/or scripts from an arbitrary terminal at any given time without having to create a new session.
推荐答案
我会建议一个类似的解决方案,为的 carandraug 的那样,只有我preFER TMUX
作为多路复用器。它可能是一个有点棘手得到正确地使创建一个shell脚本处理的细节传递的命令。
I would suggest a similar solution as carandraug did, only I prefer tmux
as the multiplexer. It may be a bit tricky getting the commands passed in correctly so create a shell-script that handles the details.
假设你已经在这样的终端启动 MATLAB
:
Let's say you've started matlab
in a terminal like this:
tmux new -s matlab "matlab -nodesktop -nojvm"
现在所谓的matlab一个 TMUX
会话运行MATLAB,没有图形用户界面。
Now a tmux
session called matlab is running matlab with no gui.
创建此shell脚本:
Create this shell-script:
MX
#!/bin/bash
if [[ $# -eq 0 ]]; then
while read; do
tmux send-keys -t matlab "$REPLY"$'\n'
done
else
tmux send-keys -t matlab "$@"$'\n'
fi
在不同的终端,你就可以执行引述MATLAB命令:
In a different terminal you can now run quoted matlab commands:
mx "A = reshape(1:9, 3, 3)"
甚至可以通过管道传递命令:
Or even pass commands in through a pipe:
for mat in A B C; do echo "$mat = reshape(1:9, 3, 3)"; done | mx
这篇关于MATLAB命令(从庆典/命令行)在一个已经运行的会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!