CGI: VBScript CGI: Difference between revisions
Punctuation and grammatical changes; some clarification. |
m spelling fix |
||
(One intermediate revision by the same user not shown) | |||
Line 3: | Line 3: | ||
'''VBScript CGI''' | '''VBScript CGI''' | ||
This page covers running | This page covers running VBScripts as CGI scripts and introduces the CGI shebang. It assumes the Apache server has been configured to permit the running of CGI scripts, and test folder vbs_test and .htaccess have been created as explained on the [[CGI: Introduction| previous page]]. | ||
__TOC__ | __TOC__ | ||
Line 62: | Line 62: | ||
The shebang is ''''!''' followed by the path to the executable that will run the script, which in this case is the Windows Script Host '''cscript.exe'''<br /> | The shebang is ''''!''' followed by the path to the executable that will run the script, which in this case is the Windows Script Host '''cscript.exe'''<br /> | ||
The '''//nologo''' prevents cscript from displaying a banner, otherwise a malformed header error | The '''//nologo''' prevents cscript from displaying a banner, otherwise a malformed header error would be produced. | ||
===Content-type=== | ===Content-type=== | ||
Following the shebang, a content type header is required. This is obligatory otherwise | Following the shebang, a content type header is required. This also is obligatory, otherwise a malformed header error would be produced. | ||
<pre> | <pre> | ||
Wscript.Echo "Content-type: text/html" & vbLF & vbLF | Wscript.Echo "Content-type: text/html" & vbLF & vbLF | ||
Line 77: | Line 77: | ||
|- | |- | ||
| | | | ||
* Edit file test1.vbs to have | * Edit file test1.vbs to have the contents as shown on right. | ||
* Start Apache if not already running | * Start Apache if not already running | ||
* Enter: <nowiki>http://localhost:8081/vbs_test/test1.vbs</nowiki><br /> (or refresh browser page) | * Enter: <nowiki>http://localhost:8081/vbs_test/test1.vbs</nowiki><br /> (or refresh browser page) | ||
Line 101: | Line 101: | ||
|- | |- | ||
| | | | ||
* Create a new file test2.vbs with | * Create a new file test2.vbs with the contents as shown on right. | ||
* Start Apache if not already running | * Start Apache if not already running | ||
* Enter: <nowiki>http://localhost:8081/vbs_test/test2.vbs</nowiki> | * Enter: <nowiki>http://localhost:8081/vbs_test/test2.vbs</nowiki> | ||
Line 119: | Line 119: | ||
| | | | ||
The script produces output as shown on right.<br /> | The script produces output as shown on right.<br /> | ||
Note: Date and time defined by your PC<br /> | Note: Date and time are defined by your PC<br /> | ||
Refresh page and note the time updates (dynamic page). | Refresh page and note that the time updates (dynamic page). | ||
|style="background:#f5f5f5;"| | |style="background:#f5f5f5;"| | ||
Line 136: | Line 136: | ||
Although the majority of html tags are optional you do need to<br /> | Although the majority of html tags are optional you do need to<br /> | ||
include a minimum set of tags as per a standard html page.<br /> | include a minimum set of tags as per a standard html page.<br /> | ||
Otherwise the page may | Otherwise the page may fail when opened in different browsers. | ||
* Create a new file test3.vbs with | * Create a new file test3.vbs with the contents as shown on right. | ||
* Start Apache if not already running | * Start Apache if not already running | ||
* Enter: <nowiki>http://localhost:8081/vbs_test/test3.vbs</nowiki> | * Enter: <nowiki>http://localhost:8081/vbs_test/test3.vbs</nowiki> | ||
Line 166: | Line 166: | ||
'''Note:''' | '''Note:''' | ||
The page title is now displayed on the browser tab and in<br /> | The page title is now displayed on the browser tab and in<br /> | ||
the browser title bar. There are no | the browser title bar. There are no other changes in output. | ||
|style="background:#f5f5f5;"| | |style="background:#f5f5f5;"| |