|
Direct CGI modeploticus may be invoked directly from URLs in HTML pages, to create plots on the fly. Direct CGI mode can produce pseudo-GIF, PNG, JPEG, SVG or SVGZ. Caution: there are CGI security concerns that must be fully understood by the programmer before using ploticus in direct CGI mode. Other strategies for on the fly graphing are discussed here.To use ploticus in direct CGI mode, copy your ploticus executable to your cgi-bin (or make a link), and create a ploticus config file (see below). The specifics of local CGI bin and file naming conventions vary; see your local admin if having difficulty. Then, use a construct such as this in your HTML page:
This is equivalent to command line usage:
cgi=1 should be the first parameter in your URL construct, as shown in the above example.
After that, the regular
ploticus command line options and arguments
, including those for
prefabs
,
may be given in the usual order. However, to
conform to URL syntax, a question mark (?) must separate the program name
from the first argument, and ampersand (&) must be used to separate subsequent
arguments. Also, arguments should not be enclosed in quotes. Use %20 to represent
an embedded space, %26 for an embedded ampersand, etc (%XX may be used to represent
any problematic character, where XX is its hex ascii value). Arguments are limited
to a length of 250 chars each and may not contain embedded newlines.
CGI MODE BEHAVIORploticus automatically goes into CGI mode if it detects the environment variable QUERY_STRING (set by your web server), and there are no conventional command line arguments given. ploticus behaves this way when in CGI mode:
TROUBLESHOOTINGUse the -debug option in your invoking URL, just after the cgi=1 argument, eg. http://abc.com/cgi-bin/pl&cgi=1&-debug&-gif.. This causes error message output to be written to /tmp/plcgi_err and diagnostic output to be written to /tmp/plcgi_diag. (If the config file is loaded successfully and a temp directory is specified there, then that directory is used instead of /tmp. For win32 c:\temp is the default.)If a preliminary error occurs, such as failure to read the config file, an error message is written to /tmp/plcgi_err regardless of whether -debug was specified. If no error message file is appearing, It is possible that ploticus was never executed. This could be because your URL path is incorrect, or your web server could not access and/or execute ploticus because of file permissions. To ensure your invoking URL is correct, verify by invoking some other CGI program in the same directory. File permissions are important. On Unix systems, be sure that your ploticus executable file mode is readable & executable by world (use command chmod 755 pl) so that your web server can execute pl. If you can, it may be desirable to set your ploticus executable file to be setuid and setgid to your own UID and group (chmod 6755 pl); then it will be able to see all files that you can see. Otherwise, ploticus will execute as your web server UID (often nobody), and you'll need to ensure that your config file and all other files needed such as script files, data files, and prefabs files are readable by world, so that your web server process can gain access (chmod 644 filenames). If you're using symbolic links, file permissions generally must be set on the actual file, not the link. Another thing to try is to simulate CGI invocation from the command line. To do this, cd to your cgi bin, deploy a new term window, and in the new window manually set the QUERY_STRING and SCRIPT_FILENAME environment variables, eg:
Full pathname should be given in SCRIPT_FILENAME so that ploticus can locate its config file. If you want your CGI to generate PNG you may need to place plpng into your cgi-bin and execute it instead of ploticus (this depends on your ploticus build). Then, in the new window, invoke ploticus by hand, with no command line arguments:
Any error messages should be visible on screen. (The output file will generally not be displayable because it contains a mime-type header.)
In theory CGI mode should work with PNG, GIF, JPEG and SVG.
I noticed some flakiness with SVG. If the ploticus script argument was
last and I was generating SVG, MSIE wouldn't display it until I added a trailing &
to the URL. And, MSIE didn't understand SVGZs when generated in CGI mode.
CGI SECURITYYou should be fully familiar with CGI security issues and how they relate to your platform and project, before putting ploticus into service as a CGI program. Some things to keep in mind:
Note: A CGI-related security hole was uncovered Feb 8 '02 and
affects versions 2.00, 2.01, and 2.02.
See
what's new page
to upgrade or apply patch.
|
![]() data display engine Copyright Steve Grubb ![]() |