@echo off :: here's an nt batch file that works as a simple cgi server :: blame: steve hardy :: shardy@seanet.com if %REQUEST_METHOD%.==GET. goto GET if %REQUEST_METHOD%.==POST. goto POST GOTO fini :: i have to cheat for the POST method, since batch doesn't want to read :: stdin without newline, which is what the web server provides. :: I do it with a line of perl, though of course that begs the question - if :: you have perl, why bother with batch...? :POST ::for /f %%a in ('getstrn.exe %HTTP_CONTENT_LENGTH%') DO SET QUERY_STRING=%%a for /f %%a in ('perl -e "my $s; read STDIN,$s,%HTTP_CONTENT_LENGTH%; print $s"') DO SET QUERY_STRING=%%a :GET if defined QUERY_STRING call :parseQS "%QUERY_STRING:+= %" :fini echo Content-Type: text/html echo. echo. :: caller can define page title... ifndef title goto body echo. echo. echo ^ echo ^%title%^ echo ^ :body echo. echo ^ echo ^ :: insert text/functionality here :: any output shows up on the page. date/t time/t :: uncomment the following for debugging ::set echo ^ echo ^ exit :: put QUERY_STRING format string into environment variable(s) :: (unescapes left as an exercise...) :parseQS if %1.==. goto :EOF FOR /f "tokens=1* delims=&" %%a in (%*) DO ( CALL :setval "%%a" CALL :parseQS "%%b") goto :EOF :setval FOR /f "tokens=1,2 delims==" %%c in (%1) DO ( SET %%c=%%d IF %%d.==. SET %%c=+) goto :EOF