Discussion:
turn off maxima command echo when I run a script in batch mode
Christiansson, G.A.V.
2005-04-20 11:31:19 UTC
Permalink
You wrote:
-----------------
Hi,

How can I turn off maxima command echo when I
run a script in batch mode ? Thanks

Regards
KC
***@LinuxDAQ-Labs.org
---------------------------

Look at the TTYOFF variable:


(%i3) describe(TTYOFF);

0: TTYOFF :(maxima.info)Definitions for Input and Output.

Info from file C:/PROGRA~1/MAXIMA~1.1/info/maxima.info:
- Variable: TTYOFF
default: [FALSE] - if TRUE stops printing output to the console.


- macro: WITH_STDOUT (file,stmt1,stmt2,...)
Opens file and then evaluates stmt1, stmt2, .... Any printing to
standard output goes to the file instead of the terminal. It
always returns FALSE. Note the binding of display2d to be false,
otherwise the printing will have things like "- 3" instead of "-3".

mygnuplot(f,var,range,number_ticks):=
block([numer:true,display2d:false],
with_stdout("/tmp/gnu",
for x:range[1] thru range[2] step
(range[2]-range[1])/number_ticks
do (print(x,at(f,var=x)))),
system("echo \"set data style lines; set title '",
f,"' ;plot '/tmp/gnu'
;pause 10 \" | gnuplot"));

(%i8) with_stdout("/home/wfs/joe",
n:10,
for i:8 thru n
do(print("factorial(",i,") gives ",i!)));
(%o8) FALSE
(%i9) system("cat /home/wfs/joe");
factorial( 8 ) gives 40320
factorial( 9 ) gives 362880
factorial( 10 ) gives 3628800
(%o9) 0
(%o3) FALSE

I usually put this line first in my .mac-files:
eval_when(batch,ttyoff : true)$

And this last:
eval_when(batch,ttyoff : false)$

In the contrib/unit/unit.mac it is done this way:
TTYOFF: NOLABELS, TRUE$

Try and see what fits you best.

Best regards,
Goran
###########################################

This message has been scanned by F-Secure Anti-Virus for Microsoft Exchange.
For more information, connect to http://www.f-secure.com/
KC
2005-04-20 18:43:33 UTC
Permalink
Hi,

Set TTYOFF to TRUE will turn off all output, which is not exactly
what I expected.

What I'm looking for is the method to turn off the command echo (C labels)
when I run the script in batch mode.

For example, assume that I have a script call analysis.max, which will do
some analysis ... and I want "maxima -b analysis.max" only show the
me the final result of the analysis, not the detail procedure or steps
inside "analysis.max".

Thanks anyway.


Regards
KC
Post by Christiansson, G.A.V.
-----------------
Hi,
How can I turn off maxima command echo when I
run a script in batch mode ? Thanks
Regards
KC
---------------------------
(%i3) describe(TTYOFF);
0: TTYOFF :(maxima.info)Definitions for Input and Output.
- Variable: TTYOFF
default: [FALSE] - if TRUE stops printing output to the console.
- macro: WITH_STDOUT (file,stmt1,stmt2,...)
Opens file and then evaluates stmt1, stmt2, .... Any printing to
standard output goes to the file instead of the terminal. It
always returns FALSE. Note the binding of display2d to be false,
otherwise the printing will have things like "- 3" instead of "-3".
mygnuplot(f,var,range,number_ticks):=
block([numer:true,display2d:false],
with_stdout("/tmp/gnu",
for x:range[1] thru range[2] step
(range[2]-range[1])/number_ticks
do (print(x,at(f,var=x)))),
system("echo \"set data style lines; set title '",
f,"' ;plot '/tmp/gnu'
;pause 10 \" | gnuplot"));
(%i8) with_stdout("/home/wfs/joe",
n:10,
for i:8 thru n
do(print("factorial(",i,") gives ",i!)));
(%o8) FALSE
(%i9) system("cat /home/wfs/joe");
factorial( 8 ) gives 40320
factorial( 9 ) gives 362880
factorial( 10 ) gives 3628800
(%o9) 0
(%o3) FALSE
eval_when(batch,ttyoff : true)$
eval_when(batch,ttyoff : false)$
TTYOFF: NOLABELS, TRUE$
Try and see what fits you best.
Best regards,
Goran
###########################################
This message has been scanned by F-Secure Anti-Virus for Microsoft Exchange.
For more information, connect to http://www.f-secure.com/
Albert Reiner
2005-04-20 19:23:28 UTC
Permalink
Post by KC
For example, assume that I have a script call analysis.max, which will do
some analysis ... and I want "maxima -b analysis.max" only show the
me the final result of the analysis, not the detail procedure or steps
inside "analysis.max".
Try load() and disp[lay]() the final result. I believe that worked
for me.

Albert
Wolfgang Jenkner
2005-04-22 14:35:21 UTC
Permalink
Post by Albert Reiner
Post by KC
For example, assume that I have a script call analysis.max, which will do
some analysis ... and I want "maxima -b analysis.max" only show the
me the final result of the analysis, not the detail procedure or steps
inside "analysis.max".
Try load() and disp[lay]() the final result. I believe that worked
for me.
As a variation on the theme, on the assumption that the `final result'
is actually computed by the very last line in the batch file (not even
followed by a comment) the following (sh quoting style) command line
avoids any "instrumentation" of the batch file

maxima --batch-string='batch("analysis.max"),ttyoff:true;%;'

This still shows the c-lines from before and after batching the file,
though.

Wolfgang

Loading...