#!/usr/bin/perl -s ## This is /wwwhome/cgi-bin/get2sas.pl ## Provides get-mode cgi-bin interface between web URL's and SAS and logs usage. ## Variation of getsas.pl in which we create temp files and count them to limit the # of invocations ##!/usr/local/bin/perl5.001 -s ## modeled after postcgi2sas.pl by Hendrik Meij, CIESIN (at the time) ## jgb Last edit, 2-26-2000 ####################################################### ## Change value of topdir to work with applications stored in other program libraries $topdir = "/wwwhome/uic/uicapps"; $pid = $ENV{"JOBPID"}; if ($pid eq '') { $pid=$$; $ENV{"JOBPID"} = $pid; }; $jobpid = "$pid.get2sas"; ## this tmpdir actually points to /tmp/scratch/uic-tmp $tmpdir = "$topdir/tmp"; #--added autoexec option 6.19.01 after sas612 reinstalled without an autoexec.sas in root dir. $saspkg = "/vendor/sas612/sas -nonews -memsize 40m -sortsize 32m -autoexec /mscdc/sascode/autoexec.sas"; $sasuser = "-sasuser $tmpdir"; $saswork = "-work /tmp/scratch"; $sasroot = "-set sasroot /vendor/sas612"; $sascmd = "$saspkg $sasuser $saswork $sasroot" ; #$cat = "/bin/cat"; $cat = "/usr/bin/cat"; $rsh = "/usr/bin/rsh"; $wc = "/usr/bin/wc"; $appmax = 12; ####################################################### #--new stuff taken from passthru.pl script $date = "/usr/bin/date"; $remhost = $ENV{"REMOTE_HOST"}; $remaddr = $ENV{"REMOTE_ADDR"}; $request = $ENV{'QUERY_STRING'}; # main if ($ENV{'REQUEST_METHOD'} eq "POST") { # ¤t_env; read(STDIN, $sec_request, $ENV{'CONTENT_LENGTH'}); $content_length = $ENV{"CONTENT_LENGTH"}; # for rsh } elsif ($ENV{'REQUEST_METHOD'} eq "GET" ) { ## ¤t_env; $sec_request = $ENV{'QUERY_STRING'}; } ###if ($remhost eq "y701.inktomi.com") { if ($remhost =~ /inktomi\.com$/) { $msg1="Sorry, $remhost, but we have canceled your privileges to run applications on this server due to excessive use."; $msg2="Please contact John Blodgett at blodgettj\@umsystem.edu if you have a question about this."; &print_errmsg; exit; } if ($remaddr =~ /209.73.164./) { exit;} if ($remaddr =~ /209.131.63./) { exit;} if ($remaddr =~ /216.35.146./) { exit;} ($pgm_pair,$rest)=split('&',$sec_request,2); # print "$pgm_pair $jobpid \n" ; ($pgmtag,$saspgm)=split('=',$pgm_pair); # print "$pgmtag $saspgm \n"; system("echo \"JOBPID=$jobpid DATE=`$date` REMOTE_HOST=$remhost REMOTE_ADDR=$remaddr $request \" >> $topdir/get2sas.logs\&"); # Adding this code 9-99 to limit number of concurrent uses $how_many =`ls $tmpdir/*.get2sas.lock | $wc -l`; #--mod 1-19-00 to replace $jobpid with $pid in naming the lock file--; if ($how_many < $appmax) { system("touch $tmpdir/$pid.get2sas.lock"); mkdir("$tmpdir/$jobpid",0777); chdir "$tmpdir/$jobpid"; symlink("$topdir/$saspgm\.sas","$saspgm\.sas"); system("echo \"$sec_request\" | $sascmd $saspgm\.sas"); } else { $msg1 = "Sorry -- we have reached our limit of $appmax concurrent web sessions running SAS."; $msg2 = "Please try again later. "; &print_errmsg; exit; } system("rm -f $tmpdir/$pid.get2sas.lock"); # end main sub current_env { # dump environment subroutine foreach(sort keys %ENV) { print "$_ = $ENV{$_}\n"; } } sub print_errmsg { # print error message print "Content-type: text/html\n\n\n"; print " Submission Status Message


Your submission has been cancelled.

$msg1

$msg2


"; }