Why is the MATLAB startup option '-r' not working properly on C UNIX Shell?
조회 수: 4 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2013년 4월 23일
편집: MathWorks Support Team
2023년 9월 8일
When I run either of the following commands in my C UNIX Shell:
matlab -nojvm -nodisplay -r "ver; quit;" > out.txt &
nohup matlab -nodisplay -nodesktop -nojvm -nosplash -r "ver;quit" > out.txt &
and issue the command
jobs
I receive the following output which indicates that MATLAB process is suspended:
Suspended (tty output) matlab -nojvm -nodisplay -r ver; quit; >& out.txt
채택된 답변
MathWorks Support Team
2023년 9월 8일
편집: MathWorks Support Team
2023년 9월 8일
NOTE: Starting in R2019b, the '-r' option is no longer recommended for non-interactive use. Use the '-batch' option in non-interactive scripting or command line workflows. Do not use this option with the -r option.
This is the expected behavior because when MATLAB has been started without the desktop, it expects to be able to read from standard input ('stdin'), however, when you start it in the background, it cannot read from 'stdin' and the process will be stopped.
As a workaround, you can create a text file which includes the commands you want to execute and use input redirection operator "<" instead of "-r" option. For example, assuming the file "foo.txt" includes the lines
ver;
exit;
you can execute the command
matlab -nodisplay -nodesktop -nojvm -nosplash <foo.txt >out.txt &
As another workaround, you can write a shell script which automates the process.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!