#!/usr/local/bin/perl # # -*- Perl -*- # # Dispatch the URL to one of the filter programs that makes up the DODS # server. The filter program is executed by this script using exec. If the # filter program cannot be run, return an error message. # # See the DODS_Dispatch.pm class for information about how environment # variables are used. # # NB: This script assumes that all data is rooted in the http document # directory subtree. If you want to access files outside that subtree, use a # symbolic link and make sure that your server is set to follow symbolic # links. To configure your server to follow symbolic links, add # FollowSymLinks to the Options in the access.conf file. # # $Id: nph-jg,v 1.18 1999/03/17 21:41:09 dan Exp $ # # $Log: nph-jg,v $ # Revision 1.18 1999/03/17 21:41:09 dan # Modified JGOFS_OBJECT and JGOFS_METHOD variables # # Revision 1.17 1999/03/02 19:27:27 dan # Added the shell environment variables JGOFS_OBJECT # and JGOFS_METHOD to the dispatch script so that # server installations do not require a 'jgofs' user # in /etc/passwd. # # Revision 1.16 1998/08/06 16:32:41 jimg # Fixed misuse of the read(...) member function. Return true if more data # is to be read, false is if not and error if an error is detected # # Revision 1.15 1997/10/04 00:33:16 jimg # Release 2.14c fixes # # Revision 1.14.2.3 1997/09/22 23:50:27 jimg # Fixed `Level_' stuff in queries; make sure to remove these fictitious # identifiers. # # Revision 1.14.2.2 1997/08/20 18:32:48 jimg # Fixed error in processing on $query; in JGOFS `,' serves as boolean AND so # translate `&' in a DODS CE to `,'. # # Revision 1.14.2.1 1997/08/20 17:26:58 jimg # Fixed bug where ancillary DAS/DDS were not found due to the presence of an # empty constraint expression (which confused the jg_das/jg_dds filters). # # Revision 1.14 1997/08/11 18:01:54 jimg # Fixed problem with PATH_INFO/$file_name where leading and trailing garbage # was not stripped off. # # Revision 1.13 1997/06/12 21:13:51 jimg # Changed the initialization of $file_name from the filename field of the Perl # object to PATH_INFO from the httpd's environment. # # Revision 1.12 1997/06/12 21:00:33 jimg # Removed the DODS_ROOT environment variable. # # Revision 1.11 1997/06/06 03:52:44 jimg # Rewrote to use the new Perl DODS_Dispatch class. # use Env; use DODS_Dispatch; # Set the DODS_ROOT environment variable. This is done so that the filter # programs which do the real work of the server can find gzip when it is not # on the user's PATH but *is* in DODS_ROOT/etc. NB: The filter program # appends the `etc'. # $ENV{'DODS_ROOT'} = "/usr/local/DODS-2.13"; NOT USED # Set the JGOFS_OBJECT_PATH environment variable. This variable can be # used to find the location of the JGOFS object dictionary without # requiring a 'jgofs' user defined in the passwd file. $ENV{'JGOFS_OBJECT'} = "/usr/local/apache/cgi-bin/"; # Set the JGOFS_METHOD_PATH environment variable. This variable can be # used to find the location of the JGOFS methods directory without # requiring a 'jgofs' user defined in the passwd file. $ENV{'JGOFS_METHOD'} = "/usr/local/apache/cgi-bin/"; # The DODS_Dispatch object reads information from the environment variables # and builds up a command based on the format of a DODS URL. $dispatch = new DODS_Dispatch; $query = $dispatch->query(); # Query must be munged for JGOFS. $query =~ s@&@,@; # The `Level_' names are synthesized by the JGOFS servers. Strip them off # before handing the queries to the JGOFS servers for processing. $query =~ s@Level_[^.]*\.@@g; $cgi_dir = $dispatch->cgi_dir(); $script = $dispatch->script(); # Dan pointed out that we don't want to use PATH_TRANSLATED with the jgofs # server. I made this change, but have no easy way to test it. jhrg 6/12/97 #$file_name = $dispatch->filename(); $filename = $ENV{'PATH_INFO'}; $ext = $dispatch->extension(); # Strip leading `/' and the trailing extension (e.g., `.das') from $filename # Nasty... jhrg 8/9/97 $filename =~ s@/(.*)\.$ext@$1@; # OK, the filter program to run is as follows: if ($ext eq "info") { # If the user wants to run the usage filter ($extension is `.html'), then # select that filter and send the cgi directory and API prefix as the # second argument (which is passed using $query). Note that the form of # the query is also different. $server_pgm = $cgi_dir . "usage"; $query = $cgi_dir . $script; $command = $server_pgm . " '" . $filename . "()' " . $query; } elsif ($ext eq "ver" || $ext eq "/version") { $script_rev = '$Revision: 1.18 $ '; $script_rev =~ s@\$([A-z]*): (.*) \$@$2@; $server_pgm = $cgi_dir . $script . "_dods"; $command = $server_pgm . " -v " . $script_rev . " " . $filename; } elsif ($ext eq "asc" || $ext eq "ascii") { $server_pgm = $cgi_dir . $script . "_dods"; $command = $server_pgm . " '" . $filename . "(" . $query . ")'"; # Never compress ASCII. local($ascii_srvr) = $cgi_dir . "asciival"; $command .= " | " . $ascii_srvr . " -m -- -"; } elsif ($ext eq "das" || $ext eq "dds" || $ext eq "dods") { # Otherwise, form the name of the filter program to run by catenating the # script name, underscore and the extension. $server_pgm = $cgi_dir . $script . "_" . $ext; # Note that the DAS and DDS filters should not have the ()'s if $query # is empty. If a query is passed, then those filters won't be able to # access ancillary DAS/DDS files (as of 8/20/97). jhrg if ($ext ne "dods" && $query eq "") { $command = $server_pgm . " " . $filename; } else { $command = $server_pgm . " '" . $filename . "(" . $query . ")'"; } } else { $command = ""; } if ($command ne "") { # if no error... exec($command); } else { my $script_rev = '$Revision: 1.18 $ '; $script_rev =~ s@\$([A-z]*): (.*) \$@$2@; $dispatch->print_error_message($script_rev); }