Hi all on the MacPerl list. This is my first actual post to the list, though I had sent a message to Matthias who was kind enough to reply. Here is that letter: [snipped header:)] >>I recently downloaded macperl and installed it to run with webstar >>2.0 as a cgi. I'm using the app, not the mpw. >>I'm pleased with what I have been able to get achieved so far, >>but I'm having difficulty with an administrative script >>which creates another macperl acgi on the fly. >> I can't make changes to the current version of the "on the fly" >>script unless I change its creator back to text from macperl >>cgi glue. >> (terminology probably off there) >> Is there a way to save a text code file to a macperl cgi glue >>file that will run with webstar from within an executing cgi? > >In principle, yes, either by sending MacPerl a "SAVE" AppleEvent or >by doing some Resource Manager manipulation. If you don't feel up for >either task, ask on the list; maybe somebody has already solved this. > >Matthias [snipped sig] So, here I am asking if anyone has already implemented something like this. I'll include the admin program and the text file that it reads from below. redirect_admin.acgi ++++++++++++++++++++ #!perl # Redirect_admin.acgi # # Created by Daryl Hawes (hawes@scsu.ctstateu.edu) # with much help from the macperl distribution and various # internet resources. # $eol = "\015\012"; $linkfile = "html_link_file"; $perlcgi = "autoRedirect.acgi"; $shtmlfile = "HardD:WebSTAR:includ:!redirect"; $creator = "ttxt"; $type = "TEXT"; &MacPerl::SetFileInfo($creator,$type,$perlcgi); ($creator,$type)=&MacPerl::GetFileInfo($perlcgi); print "$creator , $type $eol"; open(LINKFILE, "<". $linkfile) || die "Can't open $linkfile $eol"; open(SHTMLFILE, ">". $shtmlfile) || die "Can't open $shtmlfile $eol"; open(PERLCGI, ">". $perlcgi) || die "Can't open $perlcgi $eol"; print SHTMLFILE "<CENTER\>$eol"; print SHTMLFILE "<form method=\"get\" action=\"http://www.scsu.ctstateu.edu/cgi-bin/autoRedirect.acgi\">$eol"; print SHTMLFILE "<SELECT NAME=scsu_select SIZE=1>$eol"; &time_stamp ("started"); #&time_stamp("Done at"); $creator = "TEXT"; $type = "ttxt"; &MacPerl::SetFileInfo($creator,$type,$perlcgi); print PERLCGI <<ENDPERLCODE; #!perl # # Redirect.acgi # Daryl Hawes # simple macPerl script to send users to another page # on Southern's server quickly # adapted from sample files included in macPerl distribution. # ##################################################################### #NOTE: This file is created on the fly by redirect_admin.acgi. # Do not make changes to this file. To update this file and # the associated .shtml include file simply make changes to the # text file in the same folder called html_link_file and then # run http://www.scsu.ctstateu.edu/cgi-bin/redirect_admin.acgi # This file and ../includes/!redirect will be changed to the new # settings automatically. ##################################################################### \$eol = \"\\015\\012\"\; if (\$query = \$ENV{\"QUERY_STRING\"}) #if there is input - then place it in \{ #a variable named query$eol ENDPERLCODE # process argument list of files along with any includes @LINES = <LINKFILE>; $SIZE = @LINES; for ($i=0;$i<$SIZE;$i++) { $full_url = $LINES[$i]; $i++; $descriptive_name = $LINES[$i]; $i++; $code_name = $LINES[$i]; chop($full_url); chop($descriptive_name); chop($code_name); print PERLCGI "if (\$query =~ /$code_name/i) #if the word home is in the input string then:$eol"; print PERLCGI "\{ $eol"; print PERLCGI "print \"HTTP/1.0 301 Redirect\$eol\"\;$eol"; print PERLCGI "print \"Location: $full_url\$eol\$eol\"\; $eol"; print PERLCGI "\} #redirect the client$eol$eol"; print SHTMLFILE "<OPTION VALUE=$code_name\>$descriptive_name $eol"; }; #end of for loop close(LINKFILE); print SHTMLFILE "</SELECT>$eol<BR><INPUT TYPE=\"SUBMIT\" VALUE=\"Quick Link\">$eol"; print SHTMLFILE "</FORM>$eol</CENTER>$eol"; close (SHTMLFILE); print PERLCGI <<ENDOFPERL; \}\#End of if query input. If not then just end else \#if there was no query information then: \{ print "Content-Type: text/html\$eol\$eol"\; print <<ENDHTML\; <HTML> <HEAD><TITLE>ERROR</TITLE> </HEAD> <BODY> <H1>ERROR</H1> The CGI routine you are calling requires input in the url. <BR> Please report the page that you called upon this link from to <mailto:"hawes\\\@scsu.ctstateu.edu">Hawes\\\@scsu.ctstateu.edu</A><BR> Thank you<BR> </BODY> </HTML> ENDHTML } \#exit\; ENDOFPERL close (PERLCGI); #--------------- #sub start{ #local($wday,$yday,$isdst); #don't need these #($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); # #++$mon; #correct for zero # #print ( "-----Run started at $mon\/$mday\/$year - $hour:$min:$secE\n"); #} #------------------------------------------------ print "Content-Type: text/html$eol$eol"; print <<ENDOFHTML; <CENTER><H1>Great</H1></CENTER> <font size=+2>Everything seemed to have gone off without a hitch!</FONT><BR> To be sure check and see if $PERLCGI and $SHTMLFILE have been changed properly. ENDOFHTML #_____________________________________________ sub time_stamp{ local ($now_string,$text=$_[0]); $now_string=localtime; print "\n***\u$text on $now_string\n"; } #_____________________________________________ #$creator = "MrPL"; #$type = "APPL"; #&MacPerl::SetFileInfo($creator,$type,$perlcgi); exit; +++++++++++++++++++++++++end of admin script A sample html_link_file would simply look like this: #++++++++++++++++++ http://www.scsu.ctstateu.edu/ SCSU Main Page home http://www.perl.com/ Perl at home perl http://www.yahoo.com/ The Yahoo Search Engine yahoo #++++++++++++++++++end sample html_link_file