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.
Let's say you've started matlab
in a terminal like this:
tmux new -s matlab "matlab -nodesktop -nojvm"
Now a tmux
session called matlab is running matlab with no gui.
Create this shell-script:
mx
#!/bin/bash
if [[ $# -eq 0 ]]; then
while read; do
tmux send-keys -t matlab "$REPLY"$'
'
done
else
tmux send-keys -t matlab "$@"$'
'
fi
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
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…