如何从Shell脚本调用GAP函数? [英] How can I call GAP functions from a shell script?

查看:103
本文介绍了如何从Shell脚本调用GAP函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得 GAP 软件功能的结果.这是一个交互式命令行工具,主要供从事小组理论相关主题的数学家使用.文档/常见问题解答说明了 8.1:我可以从其他程序调用GAP函数吗?/a>通常是不可能的.但是,将GAP作为子进程运行并使用管道,伪tty,UNIX FIFO或某些类似的设备与其进行通信.

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.

使用名为CrystCat(Crystallographic Groups Catalog)的程序包的示例会话如下:

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
$

更新:此推荐答案

差距支持(使用间断的stdin读入功能)

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

这篇关于如何从Shell脚本调用GAP函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆