Keil Logo

Technical Support

On-Line Manuals

RL-ARM User's Guide (MDK v4)

RL-RTX RL-FlashFS RL-TCPnet TCP Socket Opening TCP Connection TCP Active Open TCP Passive Open Sending TCP Data Example for Sending Data Multiple TCP Connections UDP Socket Opening UDP Connection Sending UDP Data When DHCP Enabled When ARP Cache Empty Example for Sending Data IP Multicasting Multiple UDP Connections Configuring RL-TCPnet Static Configuration System Definitions Ethernet Network Interface PPP Network Interface SLIP Network Interface UDP Socket TCP Socket BSD Socket HTTP Server Telnet Server TFTP Server TFTP Client FTP Server FTP Client DNS Client SMTP Client SNMP Agent SNTP Client Error Function Runtime Configuration Library Files Using RL-TCPnet Stand Alone With RTX Kernel Event Driven Operation IP Address Assignment Ethernet Interface PPP Interface SLIP Interface Localhost Applications HTTP Server Script Language CGI Functions Ajax Support Using XML XML Example How it works SOAP Support SOAP Interface Large POST Messages Web Pages Default Page Error Pages Web on SD Card Web Update File System Interface Http Caching How it works Internal Web External Web Multi-user Authentication Using RAM File System FCARM File Converter PRINT Directive NOPRINT Directive PAGEWIDTH Directive PAGELENGTH Directive ROOT Directive Telnet Server Command Line Interface Multi-user Authentication Sending Reply Message Short Reply Long Reply Continuous Screen Update TFTP Server File System Interface TFTP Client File System Interface FTP Server File System Interface Multi-user Authentication Supported Commands FTP Client File System Interface SMTP Client SNMP Agent MIB Database MIB Interface MIB Entry MIB Table DNS Resolver Starting DNS Device Drivers Ethernet Driver Interrupt Mode Modem Driver Serial Driver Using Serial Link Cable Connection Modem Connection Windows Dial-up Add Direct Serial Link New Dial-up Connection Configure PPP Dial-up Configure SLIP Dial-up Debugging Enabling Debug Debug Level Redirecting Output Function Overview BSD Routines CGI Routines Ethernet Routines FTP Routines HTTP Routines IGMP Routines Miscellaneous Routines Modem Routines PPP Routines Serial Routines SLIP Routines SMTP Routines SNMP Routines System Functions TCP Routines Telnet Routines TFTP Routines UDP Routines RL-CAN RL-USB Example Programs Library Reference Appendix

Script Language

The Embedded Web Server provides a small script language which can be used to generate true dynamic web pages. The HTTP Server processes the script source file line by line and calls the CGI functions as needed. The output from a CGI function is sent to the web client as a part of the web page.

Each script line starts with a command character which specifies a command for the script interpreter. The script language itself is simple and works as follows:

Command Description
i Commands the script interpreter to include a file from the virtual file system and to output the content on the web browser.
t Commands that the line of text that follows is to be output to the browser.
c Calls a C function from the HTTP_CGI.c file. The function may be followed by the line of text which is passed to cgi_func() as a pointer to an environment variable.
# This is a comment line and is ignored by the interpreter.
. Denotes the last script line.

Here is an example of a web page written in the script language. This web page edits or changes the system password. The web page is stored in three files (two are static, and the third (main file) is the script file that generates dynamic data).

  • The script file system.cgi contains the following:
    i password_h.inc
    c d 1 <TR><TD><IMG SRC=pabb.gif>Authentication</TD><TD><b>%s</b></TD></TR>
    t <TR><TD><IMG SRC=pabb.gif>Password for user 'admin'</TD>
    c d 2 <TD><INPUT TYPE=TEXT NAME=pw SIZE=10 MAXLENGTH=10 VALUE="%s"></TD></TR>
    t <TR><TD><IMG SRC=pabb.gif>Retype your password</TD>
    c d 2 <TD><INPUT TYPE=TEXT NAME=pw2 SIZE=10 MAXLENGTH=10 VALUE="%s"></TD></TR>
    i password_f.inc
    .
    
  • The web page header, which is static and does not change when the web page is generated, is moved into the separate header file password_h.inc. The content of the included page header file is:
    <HTML>
      <HEAD>
        <TITLE>System Settings</TITLE>
      </HEAD>
      <BODY TEXT=#000000 BGCOLOR=#ccddff LINK=#0000FF VLINK=#0000FF ALINK=#FF0000>
      <H2 ALIGN=CENTER>System Settings</H2>
      <FORM ACTION=index.htm METHOD=POST NAME=CGI>
      <TABLE BORDER=0 WIDTH=99%>
      <TR BGCOLOR=#aaccff>
        <TH WIDTH=40%>Item</TH>
        <TH WIDTH=60%>Setting</TH>
      </TR>
    
    It is included into the generated web page with the following script command:
    i password_h.inc
    
  • The web page footer is also static and is moved into the password_f.inc file. It is not changed when the web page generates but is simply included in the script.
      <TR>
        <TD>&nbsp;</TD>
        <TD>&nbsp;</TD>
      </TR>
      <TR>
        <TD></TD>
        <TD align="right">
          <INPUT TYPE=SUBMIT NAME=set VALUE="Change" id="sbm">
          <INPUT TYPE=RESET VALUE="Undo">
          <INPUT TYPE=BUTTON VALUE="Home" OnClick="location='/index.htm'">
        </TD>
      </TR>
      </FORM>
      <p>This page allows you to change the system <b>Password</b>, for the username
        <b>admin</b>. Default <b>realm</b>, <b>user</b> and <b>password</b> can be set
        in configuration file. This Form uses a <b>POST</b> method to send data back to
        a Web server. You need to click on <b>Change</b> button to activate the changes.
      </p>
      </BODY>
    </HTML>
    

This is how the generated web page looks like, with the dynamically generated items in the Setting column:

Generated Web Page

You can see the HTML source code of this web page. This data is actually sent to the web client when the client requests the web page system.cgi. The script file is processed by the script interpreter, and the following data is generated by the Web Server. You can compare the generated HTML source with the script file to see where the CGI interface comes in.

<HTML>
  <HEAD>
    <TITLE>System Settings</TITLE>
  </HEAD>
  <BODY TEXT=#000000 BGCOLOR=#ccddff LINK=#0000FF VLINK=#0000FF ALINK=#FF0000>
  <H2 ALIGN=CENTER>System Settings</H2>
  <FORM ACTION=index.htm METHOD=POST NAME=CGI>
  <TABLE BORDER=0 WIDTH=99%>
  <TR BGCOLOR=#aaccff>
    <TH WIDTH=40%>Item</TH>
    <TH WIDTH=60%>Setting</TH>
  </TR>
  <TR><TD><IMG SRC=pabb.gif>Authentication</TD><TD><b>Enabled</b></TD></TR>
  <TR><TD><IMG SRC=pabb.gif>Password for user 'admin'</TD>
  <TD><INPUT TYPE=TEXT NAME=pw SIZE=10 MAXLENGTH=10 VALUE="test"></TD></TR>
  <TR><TD><IMG SRC=pabb.gif>Retype your password</TD>
  <TD><INPUT TYPE=TEXT NAME=pw2 SIZE=10 MAXLENGTH=10 VALUE="test"></TD></TR>
  <TR>
    <TD>&nbsp;</TD>
    <TD>&nbsp;</TD>
  </TR>
  <TR>
    <TD></TD>
    <TD align="right">
      <INPUT TYPE=SUBMIT NAME=set VALUE="Change" id="sbm">
      <INPUT TYPE=RESET VALUE="Undo">
      <INPUT TYPE=BUTTON VALUE="Home" OnClick="location='/index.htm'">
    </TD>
  </TR>
  </FORM>
  <p>This page allows you to change the system <b>Password</b>, for the username
    <b>admin</b>. Default <b>realm</b>, <b>user</b> and <b>password</b> can be set
    in configuration file. This Form uses a <b>POST</b> method to send data back to
    a Web server. You need to click on <b>Change</b> button to activate the changes.
  </p>
  </BODY>
</HTML>

Note

  • The script files use the reserved filename extension of cgi. Using the cgi filename extension for script files is mandatory for the Web Server script interpreter to recognize and process the script files.
  • The script line length is limited to 120 characters.
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.