#! /bin/perl # -*- perl -*- # ------------------------------------------------------------- # file: sas.cgi (pass query to sas as macro variable assignments) # ------------------------------------------------------------- # Created Feb 6, 1997 by wvanbusk@psmfc.org # Last Change: Feb 7, 1997 by wvanbusk@psmfc.org # (c) PSMFC All Rights Reserved # Must be distributed free of charge with the above info. #================================================ #Scurity scripting may be required here if SAS and your Web server are #running on seperate machines and permissions are not set to allow #the 'rsh' command from the web user to a remote machine with SAS. #================================================ ## Timeout value in seconds for this script $TIMEOUT = "300"; # 5 minutes sub handler { local($sig) = @_; die "got a SIG$sig--exiting\n"; } # handler $SIG{'ALRM'} = "handler"; alarm($TIMEOUT); #================================================ print "Content-type: text/html\n\n"; #HTML prefix $in = $ENV{'QUERY_STRING'}; #get query @in = split(/&/,$in); #split by '&'; foreach $i (0 .. $#in) { $in[$i] =~ s/\+/ /g; #substitute '+' with ' ' (space); ($key, $val) = split(/=/,$in[$i],2); # split in two on '='; $in{$key} .= "." if (defined($in{$key})); # append key and put "." between duplicates; $in{$key} .= $val; $in{$key} =~ s/%2F/\//g; #substitute '%2F' with '/'; } $in{pid}=$$; #add process id; foreach $key (keys(%in)){ # Add SAS code to define as macro variable; $out = $out . "%let " . $key . "\=" . $in{$key} . "\; "; } if ($in{debug}) { print "