You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'!c:\WINDOWS\system32\cscript.exe /nologoWScript.Echo"Content-type: text/html"&vbcrlf' vbCrLf 是 Visual Basic中的一個字串常數,即「 Chr(13) & Chr(10) 」(回車字元與換行字元連接在一起 \n\r ),是換行的意思. 'Above two lines are required do not change'Some basic html follows:WScript.Echo"<h1>Hello World</h1>"WScript.Echo"<p>This is output from VBScript</p>"WScript.StdOut.WriteLine"<h2>Microsoft VBScript engines version</h2>"WScript.StdOut.WriteLine(_Join(Array(_ScriptEngine,ScriptEngineMajorVersion,ScriptEngineMinorVersion,ScriptEngineBuildVersion_),".")_)
在瀏覽器輸入網址 http://localhost/cgi-bin/test1.vbs。如下圖,印出 Hello world 和 VBScript 引擎版本。
'!c:/windows/system32/cscript -nologo'https://github.com/apache/httpd/blob/trunk/docs/cgi-examples/printenv.wsf ' To permit this cgi, replace 'onthefirstlineabovewiththe' appropriate shebang, f.e. '!c:/windows/system32/cscript-nologo''*****!!!WARNING!!!*****' This script echoes the server environment variables and therefore'leaksinformation-soNEVERuseitinaliveserverenvironment!' It is provided only for testing purpose.'Alsonotethatitissubjecttocrosssitescriptingattackson' MS IE and any other browser which fails to honor RFC2616. '''' printenv -- demo CGI program which just prints its environment''
<job><scriptlanguage="JScript">
WScript.Echo("Content-type: text/html; charset=utf-8");
WScript.Echo("\n");
WScript.Echo("Hello World!");
WScript.StdOut.WriteLine("<h2>Microsoft JScript engine version</h2>")
WScript.StdOut.WriteLine([
ScriptEngine(), ScriptEngineMajorVersion(), ScriptEngineMinorVersion(), ScriptEngineBuildVersion()
].join('.'));
WScript.Echo("<h2>server environment variables (伺服器環境變數)</h2>");
var objShell = new ActiveXObject("WScript.Shell");
var objArray = new Array();
var e = new Enumerator(objShell.Environment("PROCESS"));
for (;!e.atEnd();e.moveNext()) {vari=e.item().indexOf("=");varenvvar=e.item().substring(0,i);varenvval=e.item().substring(i+1,e.item().length);envval=envval.replace("\n","\\n");objArray.push(envvar+"=\""+envval+"\"");}
objArray.sort();
WScript.Echo(objArray.join("<br/>"));
</script></job>
在瀏覽器輸入網址 http://localhost/cgi-bin/printenv.wsf。如下圖,印出 Hello world 、 JScript 引擎版本和伺服器環境變數。
CGI programming in VBScript / JScript (Windows Script Host (WSH))
環境準備:假設開發環境已建立好了。參閱 #24 XAMPP 安裝與設定 (PHP, Apache, MariaDB, phpMyAdmin)。
VBScript
C:\xampp\cgi-bin\
新增一腳本test1.vbs
,該腳本內容如下:http://localhost/cgi-bin/test1.vbs
。如下圖,印出 Hello world 和 VBScript 引擎版本。JScript
C:\xampp\cgi-bin\
新增一腳本printenv.wsf
,該腳本內容如下:http://localhost/cgi-bin/printenv.wsf
。如下圖,印出 Hello world 、 JScript 引擎版本和伺服器環境變數。參考資料
The text was updated successfully, but these errors were encountered: