I want to get the result of a function of the GAP software. This is an interactive command line tool mainly for mathematician who work on group theory related topics. The documentation/faq states about 8.1: Can I call GAP functions from another programme? that it is in general not possible. However, running GAP as a child process and communicate with it using pipes, pseudo-ttys, UNIX FIFOs or some similar device it can be done.
An example session using a package called CrystCat (Crystallographic Groups Catalog) looks like:
$ gap
gap > LoadPackage( "CrystCat" );
gap > DisplaySpaceGroupType( "P1" );
#I Space-group type (3,1,1,1,1); IT(1) = P1; orbit size 1; fp-free
gap > quit;
$ # exited 'gap' and back in my shell
As I am not familiar with these techniques, can someone show me a minimal example having following functionality:
$ ./script.sh "P1"
#I Space-group type (3,1,1,1,1); IT(1) = P1; orbit size 1; fp-free
$
UPDATE: The accepted answer of this question doesn't work.
Answer by gap-support (using stdin read-in capability of gap)
#!/bin/sh
if [ "$#" != "1" ]; then
echo "Usage: test.sh <string>"
exit 1
fi;
gap -r -b -q << EOI
LoadPackage( "CrystCat" );
DisplaySpaceGroupType( "$1" );
EOI
It works exactly as asked, namely
$ ./script.sh P1
#I Space-group type (3,1,1,1,1); IT(1) = P1; orbit size 1; fp-free