version 1.14, 2013/09/22 05:17:17 |
version 1.17, 2013/10/11 01:08:35 |
|
|
% $OpenXM: OpenXM/src/kan96xx/Doc/cgi.sm1,v 1.13 2013/09/22 01:07:38 takayama Exp $ |
% $OpenXM: OpenXM/src/kan96xx/Doc/cgi.sm1,v 1.16 2013/09/25 07:30:52 takayama Exp $ |
% OpenXM/src/polymake/cgi/cgi-polymake.sh |
% OpenXM/src/polymake/cgi/cgi-polymake.sh |
% is a shell script to call sm1/polymake as a CGI script. |
% is a shell script to call sm1/polymake as a CGI script. |
% Override as /doPolymake {doPolymake.OoHG} def if you need. |
% Override as /doPolymake {doPolymake.OoHG} def if you need. |
|
|
% ------------ client side script --------------- |
% ------------ client side script --------------- |
/cgiQueryPolymake.hostname (polymake.math.kobe-u.ac.jp) def |
/cgiQueryPolymake.hostname (polymake.math.kobe-u.ac.jp) def |
/cgiQueryPolymake.cginame (/cgi-bin/cgi-polymake.sh) def |
/cgiQueryPolymake.cginame (/cgi-bin/cgi-polymake.sh) def |
%/cgiQueryPolymake { cgiQueryPolymake.curl } def |
%This host and cgi are version 2.0 polymake. dim, ... are different with new versions. |
/cgiQueryPolymake { cgiQueryPolymake.native } def |
/cgiQueryPolymake { cgiQueryPolymake.curl } def |
|
%/cgiQueryPolymake { cgiQueryPolymake.native } def |
/cgiQueryPolymake.curl { |
/cgiQueryPolymake.curl { |
/arg2 set /arg1 set |
/arg2 set /arg1 set |
[/saction /sfile /ff /ff1 /sss2 /goo /pp /pp2 /key /body /fd] pushVariables |
[/saction /sfile /ff /ff1 /sss2 /goo /pp /pp2 /key /body /fd] pushVariables |
|
|
(/tmp/sm1-q-cgi.txt) (w) file /fd set |
(/tmp/sm1-q-cgi.txt) (w) file /fd set |
fd body writestring |
fd body writestring |
fd closefile |
fd closefile |
[(curl) (--form) [key (=@/tmp/sm1-q-cgi.txt)] cat ff1] /ff set |
% [(curl) (--form) [key (=@/tmp/sm1-q-cgi.txt)] cat ff1] /ff set |
ff message |
% ff addStdoutStderr oxshell @@@stdout /pp set |
ff |
[(curl --form ) [key (=@/tmp/sm1-q-cgi.txt )] cat ff1 (>/tmp/sm1-q-cgi-out.txt)] cat /ff set |
addStdoutStderr oxshell |
ff system |
@@@stdout /pp set |
[nl (/tmp/sm1-q-cgi-out.txt) pushfile] cat /pp set |
pp message |
|
@@2stderr message |
|
(-----) message |
|
% For the case of error. |
|
[(regexec) (200 OK) [pp]] extension length 0 eq { |
|
(sss2=) message |
|
sss2 message |
|
(pp=) message |
|
pp message |
|
(cgi.sm1: there seems to be an error in the HTTP connection.) |
|
} { } ifelse |
|
|
|
cgi.verbose { pp message } { } ifelse |
cgi.verbose { pp message } { } ifelse |
[(cgiHttpToKeyValuePair) pp] extension /pp2 set |
[(cgiHttpToKeyValuePair) pp] extension /pp2 set |
|
pp2 message |
% step 3. Analyze the response. |
% step 3. Analyze the response. |
[pp2 (Content-Body) getNode |
[pp2 (Content-Body) getNode |
pp2 (oxshell-stdout) getNode |
pp2 (oxshell-stdout) getNode |
|
|
%/polymake.start { polymake.start.OoHG } def |
%/polymake.start { polymake.start.OoHG } def |
|
|
[(doPolymake.OoHG) |
[(doPolymake.OoHG) |
[(It first looks for local polymake. If there is, it calls the local polymake.) |
[(doPolymake.local calls the local polymake.) |
(If not, it calls http://polymake.math.kobe-u.ac.jp/cgi-bin/cgi-polymake.sh) |
(This function calls http://polymake.math.kobe-u.ac.jp/cgi-bin/cgi-polymake.sh) |
(to make a computation in polymake.) |
(to make a computation in polymake.) |
|
(The host name and the cgi name are set to the variable) |
|
( cgiQueryPolymake.hostname and cgiQueryPolymake.cginame) |
(See doPolymake for the syntax. doPolymake.OoHG may overrides doPolymake.) |
(See doPolymake for the syntax. doPolymake.OoHG may overrides doPolymake.) |
|
(If you use curl to call the server execute) |
|
( usePolymake.OoHG.curl) |
|
(after loading cgi.sm1) |
]] putUsages |
]] putUsages |
/doPolymake.OoHG { |
/doPolymake.OoHG { |
/arg1 set |
/arg1 set |
|
|
% cgi-polymake |
% cgi-polymake |
(Trying web service.) message |
(Trying web service.) message |
pAction pNative cgiQueryPolymake /doPolymake.OoHG.result set |
pAction pNative cgiQueryPolymake /doPolymake.OoHG.result set |
|
doPolymake.OoHG.result /@@@doPolymake.vars set |
[(regexec) (Not Found) [doPolymake.OoHG.result 0 get ]] |
[(regexec) (Not Found) [doPolymake.OoHG.result 0 get ]] |
extension length 0 eq not { |
extension length 0 eq not { |
doPolymake.OoHG.result message |
doPolymake.OoHG.result message |
|
|
(polymake2tfb is not installed in this system.) error |
(polymake2tfb is not installed in this system.) error |
} { } ifelse |
} { } ifelse |
} def |
} def |
|
|
|
|
|
/usePolymake.local { |
|
/doPolymake { doPolymake.local } def |
|
/polymake.start { polymake.start.local } def |
|
} def |
|
|
|
/usePolymake.OoHG.native { |
|
/doPolymake { doPolymake.OoHG } def |
|
/polymake.start { polymake.start.OoHG } def |
|
/cgiQueryPolymake { cgiQueryPolymake.native } def |
|
} def |
|
|
|
/usePolymake.OoHG.curl { |
|
[(which) (curl)] oxshell tag 0 eq { |
|
(Error in usePolymake.OoHG.curl: curl is not found.) error |
|
} { } ifelse |
|
/doPolymake { doPolymake.OoHG } def |
|
/polymake.start { polymake.start.OoHG } def |
|
/cgiQueryPolymake { cgiQueryPolymake.curl } def |
|
} def |
|
|
|
[(usePolymake.local) |
|
[(doPolymake calls local polymake) |
|
]] putUsages |
|
|
|
[(usePolymake.OoHG.native) |
|
[(doPolymake = doPolymake.OoHG with cgiQueryPolymake.native) |
|
(cf. doPolymake.OoHG) |
|
(hostname is set in cgiQueryPolymake.hostname) |
|
(cginame is set in cgiQueryPolymake.cginame) |
|
]] putUsages |
|
|
|
[(usePolymake.OoHG.curl) |
|
[(doPolymake = doPolymake.OoHG with cgiQueryPolymake.curl) |
|
(It should be used when cgiQueryPolymake.native does not work) |
|
(over, e.g., a reverse proxy.) |
|
(The command curl is required. cf. cgi.verbose, doPolymake.OoHG) |
|
(hostname is set in cgiQueryPolymake.hostname) |
|
(cginame is set in cgiQueryPolymake.cginame) |
|
]] putUsages |
|
|
|
|
|
|
|
|
|
|
|
|
|
|