Why is the MATLAB startup option '-r' not working properly on C UNIX Shell?

31 views (last 30 days)

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

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 23 Apr 2013
This is the expected behavior because when MATLAB has been started without the desktop, it expects to be able to read from standart 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.

More Answers (0)

Products


Release

R2007a

Community Treasure Hunt

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

Start Hunting!

Translated by