Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you use GAP in batch mode?

Tags:

gap-system

I can't seem to figure out how to use the GAP computer algebra system (for example, if I have a python script, I can do python script.py > /tmp/python_output.csv) I can't seem to find any info in the GAP documentation [I am sure it is there somewhere])

like image 611
Igor Rivin Avatar asked Dec 29 '25 09:12

Igor Rivin


1 Answers

Using gap script.g works fine, but it does not terminate GAP at the end, but rather switches to the REPL at the end. To change that, you can end your script with QUIT;. Or, if you use GAP >= 4.11.0, you can add -c 'QUIT;' at the end of the command line to achieve the same effect for any script, without modifying it.

In addition, you may want to turn off the banner with -b and enable quiet mode with -q. Finally, you can use --quitonbreak to disable the break loop so that errors terminate instead of resulting in a hang waiting for user input.

In summary:

gap --quitonbreak -b -q script.g

or if you don't want to end your script with QUIT;, use

gap --quitonbreak -b -q script.g -c 'QUIT;'

If you feel the need to do this a lot, you could wrap this into a little helper shell script gap-batch which looks something like this:

#!/bin/sh
gap --quitonbreak -b -q $* -c 'QUIT;'

If you put this into your PATH, then you can just do

gap-batch script.g
like image 192
Max Horn Avatar answered Jan 01 '26 03:01

Max Horn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!