| QG | /YeP-perl/Addons/Shtml/Background |
This is a kind of "SSI for IIS". Have you ever tried to port some
.shtmlpages that use SSI to HTTP server that does not support SSI? Here is a hack that provides some kind of SSI functionality. It also may be counted as an example of how to implement PHP/ASP-like functionality with the help of perl.
#!/qub/perl # (c) Qub Group. 1998. # See http://www.qub.com for details of Qub Group YeP-perl project. # # Script to emulate SSI on IIS. # # It allows you to have .shtml files with strings <!--exec cgi="/action" --> # working with IIS. # # With regedt32 associate .shtml extension with the command: # C:\qub\perl.exe C:\qub\Addons\shtml\shtml.pl %s # # See: HKEY_LOCAL_MACHINE # System -> CurrentControlSet -> Services -> W3SVC -> Parameters ->Script Map # Don't forget to restart IIS service. # # Created when porting mSQL Keeper v 2.1 to Windows NT. # # Hack is quick and dirty. # /virtual/dir assumed to be /real/dir. # cgi= may be not only a perl script. # You may speedup this script by avoiding # invocation of second copy of perl with the help of 'do' or 'eval'. # $DOCUMENT_URI is not passed to SSI. e t.c. e t.c. # # ... But it works and is easely expandable. # # Be sure that you have /bin/sh or comment out 2>&1 otherwise # #print "HTTP/1.0 200 OK\n"; print "Content-type: text/html\n\n"; $param=$ARGV[0] or die "Provide file to process"; open (IN, "< $param" ) or die "error opening $param"; while(<IN>) { if ( /(.*)(<!--#exec cgi=")([^"]*)" -->(.")/ ) { ($head,$script,$tail)=($1,$3,$4); if ( $script =~ /(.*)\/([^\/]*$)/) { $path=$1; } else { die "internal error"; } # print "Invoking $script with -I$path\n"; $res = `perl -I$path $script 2>&1`; $res =~ s/Content-type: text\/html\n\n//g; print "$head $res $tail"; } else { print $_; } } close IN;Take and use the complete Shtml package.
- Download and install Cygwin 'Usertool' and YeP-perl core distribution.
- Download and use YeP-perl Mountall Addon. Be sure you have
/qub /bin /etc /tmpand root (/) really mounted.- Download YeP-perl Shtml Addon. It is self-descriptive.
Not tested with Windows 95. Have no Win95 computers at hand. Wanna become YeP-perl-for-Win95 tester?
Find a bug? Have a suggestion? Have a business proposal? - do tell.
| QG | /YeP-perl/Addons/Shtml/Background |