I am trying to run a matlab file on a remote host. I have an account on the machine and I can access the linux command line when I log in. The line I enter on the command line is:
nohup matlab -nojvm -r "My_script" > My_script_out.txt&
I have placed the 'exit' command at the end of the file 'My_script' but Matlab seems to go into a never ending loop and prints 'bad file descriptor' in the output file when it finishes executing the matlab script. The matlab file runs till completion but the problem is that my output textfile becomes large as a result of the continuous print of the 'bad file descriptor' line. After completion, this is what is printed in the file:'
>> Warning:
Connection to the X11 Display Server (localhost:10.0) has been lost. No more graphics windows can no longer be displayed in this session. Graphics Objects can still be printed, and all commands should still work. We recommend that you try to save your current session and exit
>> Bad file descriptor
Bad file descriptor
Bad file descriptor...
Has anyone encountered this problem and if so, what is the solution?
I made a test scipt
function test()
for i=1:10
fprintf('line %d\n',i);
end
return
then issued
> nohup matlab -nodesktop -nosplash -r test 2>/dev/null 1>out.txt &
The file out.txt grew quite quickly into > 1GB fil (in some minute). Then I killed the job. And wrote
>tail -4 out.txt
Warning: Error reading character from command line
Warning: Error reading character from command line
Warning: Error reading character from command line
Warning: Error reading character from command line
Then I write:
>head -30 out.txt
< M A T L A B (R) >
Copyright 1984-2010 The MathWorks, Inc.
Version 7.12.0.635 (R2011a) 64-bit (glnxa64)
March 18, 2011
To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
line 10
>> Warning: Error reading character from command line
Warning: Error reading character from command line
>> Warning: Error reading character from command line
Warning: Error reading character from command line
>> Warning: Error reading character from command line
Warning: Error reading character from command line
>> Warning: Error reading character from command line
Warning: Error reading character from command line
Warning: Error reading character from command line
Warning: Error reading character from command line
Then I changed the script to include "exit" at the end:
function test()
for i=1:10
fprintf('line %d\n',i);
end
exit
return
Now it work fine. The out.txt file now contains
>cat out.txt
< M A T L A B (R) >
Copyright 1984-2010 The MathWorks, Inc.
Version 7.12.0.635 (R2011a) 64-bit (glnxa64)
March 18, 2011
To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
line 10
So for me, I seem to have a solution when I put "exit" at the end of the script...
Regards
Haakon Haegland