From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- noao/obsutil/src/doc/cgiparse.hlp | 166 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 noao/obsutil/src/doc/cgiparse.hlp (limited to 'noao/obsutil/src/doc/cgiparse.hlp') diff --git a/noao/obsutil/src/doc/cgiparse.hlp b/noao/obsutil/src/doc/cgiparse.hlp new file mode 100644 index 00000000..f054ca4e --- /dev/null +++ b/noao/obsutil/src/doc/cgiparse.hlp @@ -0,0 +1,166 @@ +.help cgiparse Mar03 noao.obsutil +.ih +NAME +cgiparse -- parse STRING_QUERY environment var. into parameters +.ih +SYNOPSIS +CGIPARSE parses the STRING_QUERY environment varabile and sets parameters. +The string format is a list of task.param=value pairs which includes the +standard QUERY string special characters '&', '+', and '%'. This is +intended to parse a query from a CGI script. +.ih +USAGE +cgiparse +.ih +PARAMETERS +There are no parameters. The input is the value of the QUERY_STRING +environment variable. +.ih +DESCRIPTION +CGIPARSE parses the STRING_QUERY environment varabile and sets parameters. +The string format is a list of task.param=value pairs which includes the +standard QUERY string special characters '&', '+', and '%'. This is +intended to parse a query from a CGI script. + +The only input is the STRING_QUERY variable. If it is undefined the +task simply does nothing. The string will normally use the standard +parameters for this type of string. The data fields are task.param=value +strings. As each is parsed the values will be set for the task. This +assumes the tasks are defined. Theere is no error checking for +undefined tasks or parameters. +.ih +EXAMPLES +1. A CGI script calls a CL script with the STRING_QUERY string set. +The string has "imheader.longheader=yes". CGIPARSE is called and +when it completes the parameter value is set. + +.nf + cl> lpar imhead + cl> lpar imheader + images = image names + (imlist = "*.imh,*.fits,*.pl,*.qp,*.hhh") default image ... + (longheader = no) print header in multi-line format + (userfields = yes) print the user fields ... + (mode = "ql") + cl> cgiparse + cl> lpar imheader + images = image names + (imlist = "*.imh,*.fits,*.pl,*.qp,*.hhh") default image ... + (longheader = yes) print header in multi-line format + (userfields = yes) print the user fields ... + (mode = "ql") +.fi + +Note that when running this in a "#!cl" script where the "login.cl" is +not used that you must be careful to have all tasks referenced by the +query string defined. + +2. Below is a "#!cl" type script that uses CGIPARSE. It is used for +a spectral exposure time calculator based on OBSUTIL.SPTIME though many +aspects are fairly generic for this type of application. + +.nf +#!/iraf/iraf/bin.freebsd/cl.e -f + +file urldir + +# The following must be set for different hosts. +# The home directory and the urldir are the same but in different syntax. +# The home directory must have a world writable tmp subdirectory. + +set arch = ".freebsd" +set (home = osfn ("/www/htdocs/noao/staff/brooke/gsmt/")) +urldir = "/noao/staff/brooke/gsmt/" + +# The uparm is a unique temporary directory. +s1 = mktemp ("uparm") // "/" +set (uparm = "home$/tmp/" // s1) +mkdir uparm$ +cd uparm +printf ("!/bin/chmod a+rw %s\n", osfn("uparm$")) | cl + +# The URL directory is the same as uparm. +urldir = urldir // "tmp/" // s1 + +# A private graphcap is required to give an path for sgidispatch. +set graphcap = home$graphcap + +# Load packages. +dataio +proto +noao +onedspec +spectime +gsmt + +# Parse the CGI string and set parameters. +cgiparse + +# Create the output. + +# Start HTML. +printf ("Content-Type: text/html\n\n") +printf ("Test\n") +printf ("\n") +if (cl.line == "...") + printf ("

SPECTIME

\n", cl.line) +else + printf ("

%s

\n", cl.line) +printf ("
\n")
+
+# Execute task(s).
+#show QUERY_STRING
+
+setup interactive=no mode=h
+printf ("
\n") +printf ("Back to form") +printf ("
\n")
+
+sptime output="counts,snr" graphics="g-gif" interactive=no mode=h
+
+printf ("
\n") +printf ("Back to form\n") + +printf ("
\n")
+
+# Add any gifs created.  We have to wait for them to be created.
+
+gflush
+
+i = 0; j = 1
+while (i != j) {
+    sleep 2
+    j = i
+    files *.gif | count STDIN | scan (i)
+}
+
+
+if (i > 0) {
+    printf ("

Note: DN and S/N are per-pixel
\n") + + files *.gif > gifs + list = "gifs" + while (fscan (list, s1) != EOF) { + if (access (s1)) + printf ("\n", urldir, s1) + } + list = "" + ## delete ("uparm$gifs", verify-) +} + +printf ("

\n") + +# Finish HTML. + +printf ("Back to form") + +printf ("\n") + +# Clean up. +## delete ("*[^g][^i][^f]", verify-) + +logout +.fi +.ih +SEE ALSO +.endhelp -- cgit