clean up standard output when running in background

6 visualizzazioni (ultimi 30 giorni)
pfb
pfb il 20 Ott 2014
Commentato: pfb il 14 Apr 2015

Hi all,

I often run matlab in background, by issuing the following command in linux or mac OS (bash)

nohup matlab -nodesktop -nosplash -nodisplay -nojvm < code.m &> out.txt &

This launches the script code.m in a background instance of matlab and redirects the relevant standard output and standard error into out.txt.

The latter file contains a couple of features I'd like to get rid of

1) the matlab "textual splash screen" (the one appearing in the command window when launching matlab in interactive graphical mode)

2) a variable number of consecutive instances of the prompt ">>".

For instance the following code

fprintf('\n\n\n\n');
a=1;
fprintf('hello\n');
b=2;
warning('whoa');
c = 3;
fprintf('\n\n\n\n');
fprintf('%d\n',c);
for j=1:3
    fprintf('%d %d\n',j,c*j);    
end
error('hey!!');
exit;

produces the following output

                                < M A T L A B (R) >
                      Copyright 1984-2010 The MathWorks, Inc.
                    Version 7.12.0.635 (R2011a) 64-bit (maci64)
                                   March 18, 2011
      To get started, type one of these: helpwin, helpdesk, or demo.
      For product information, visit www.mathworks.com.
>> 
>> >> hello
>> >> Warning: whoa 
>> >> 
>> 3
>> 1 3
2 6
3 9
>> ??? hey!!
>> >> 

I'd like to get rid of the "splash screen", although I can live with it.

What I find really annoying is the apparently random appearance of the prompts ">>". With more complex codes much longer sequences of ">>" appear.

I know I could print my output in some output file, instead of the stdout. But getting rid of all the above stuff would simplify my life.

Anyone has any idea of why I'm getting these ">>" and how can I get rid of them?

Thanks a lot for any help

Francesco

UPDATE

- I tried placing clc before the first fprintf, but had no effect;

- The same "problem" affects the most recent version of matlab I've got, i.e. matlab R2014b

Risposte (1)

Titus Edelhofer
Titus Edelhofer il 14 Apr 2015
Hi Francesco,
have you tried to use the diary function instead of redirection of output?
doc diary
I'm not sure, but it should not print out the command prompt, if I remember correctly ...
Titus
  1 Commento
pfb
pfb il 14 Apr 2015
Hi Titus,
thanks for the suggestion. I never used this function.
From a quick look it produces a formatted output, but I might be wrong.
I am fine with the redirected standard output, except for the first few lines, which are affected by the ">>" problem.
Actually, that's not a big deal either, but I was curious on whether it can be fixed somehow.
Anyway I'll look further into diary and experiment a bit.
Cheers
Francesco

Accedi per commentare.

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by