Annotation of OpenXM/src/Macaulay2/m2/curl.m2, Revision 1.1
1.1 ! takayama 1: ID=" $OpenXM$ "
! 2:
! 3: -- curl interface for M2
! 4:
! 5: curl = method()
! 6: curl(String,String) := (s,url) -> (
! 7: try (F := get ("!curl " | s | " " | url))
! 8: else ( error "Could not start curl " | s | " " | url);
! 9: F
! 10: )
! 11:
! 12: test1 = method()
! 13: test1(ZZ) := (ttype) -> (
! 14: ans1=
! 15: curl("--data 'oxMessageBody=fd_hessian2(-2,[-3,-2],10,[1/2,1/3])'",
! 16: "http://asir2.math.kobe-u.ac.jp/cgi-bin/cgi-asir-r-fd2.sh");
! 17: print(ans1);
! 18: ans2=
! 19: curlPostMessage("oxMessageBody=fd_hessian2(-2,[-3,-2],10,[1/2,1/3])",
! 20: "http://asir2.math.kobe-u.ac.jp/cgi-bin/cgi-asir-r-fd2.sh");
! 21: ans2
! 22: )
! 23:
! 24: -- --data-urlencode should be used for new curl.
! 25: curlPostMessage = method()
! 26: curlPostMessage(String,String) := (data,url) -> (
! 27: curl("--data " | "'" | data | "'", url)
! 28: )
! 29:
! 30: -- Translate list expressions among asir and M2
! 31: asir2m2 = method()
! 32: asir2m2(String):= (s) -> (
! 33: s2=replace("\\[","{",s);
! 34: replace("\\]","}",s2)
! 35: )
! 36: m22asir = method()
! 37: m22asir(String):= (s) -> (
! 38: s2=replace("\\{","[",s);
! 39: replace("\\}","]",s2)
! 40: )
! 41:
! 42: -- Example: fdHessian2(-2,{-3,-2},10,{1/2,1/3})
! 43: fdHessian2 = method()
! 44: fdHessian2(ZZ,List,ZZ,List):= (a,b,c,x) -> (
! 45: strategy = "asir2-cgi";
! 46: url = "http://asir2.math.kobe-u.ac.jp/cgi-bin/cgi-asir-r-fd2.sh";
! 47: if (strategy == "asir2-cgi") then (
! 48: s = toString(a) | "," | m22asir(toString(b)) | "," |
! 49: toString(c) | "," | m22asir(toString(x));
! 50: s = "oxMessageBody=fd_hessian2(" | s | ")";
! 51: ans = curlPostMessage(s,url);
! 52: if (match("error",ans)) then error(ans);
! 53: h=value(asir2m2(ans));
! 54: );
! 55: h
! 56: )
! 57:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>