| ioPAC RTU Controllers C/C++ Sample Code Programming Guide

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Web.HOWTO File Reference

HOWTO: Entry of CGI Samples More...

## Detailed Description

HOWTO: Entry of CGI Samples

Copyright
  Moxa Inc.

Date
  11-11-2014

Author
  Wanhan Hsieh

Version
  V1.0
  Entry of CGI Samples

    Introduction:
    This is the introduction of HOWTO use the entry of CGI sample(cgi_entry.html).

Start Web server:

    root@Moxa:/home# /etc/init.d/apache start
    Starting web server: apache.

Build and Run the sample:

1. Build samples on PC:

       root@PLATFORM:/# cd /usr/local/arm-linux/sample/RTU/Web
       root@PLATFORM:/usr/local/arm-linux/sample/RTU/Web# make
       root@PLATFORM:/usr/local/arm-linux/sample/RTU/Web# ls
       cgi-bin htdocs Makefile source

2. Copy cgi-bin and htdocs to the ioPAC's /home/httpd/ (ex. FTP)
3. Change file mode on ioPAC:

       root@Moxa:/# cd /home/httpd/
       root@Moxa:/home/httpd# chmod 755 cgi-bin/*
       root@Moxa:/home/httpd# chmod u+s cgi-bin/*
       root@Moxa:/home/httpd# chmod 755 htdocs/*

4. Run the sample through the Web browser:
   Using default URL: http://192.168.127.254/cgi_entry.html

Source code: cgi_entry.html

    <html>
    	<head>
    		<link href="iopac.css" rel="stylesheet" />
    		<title>Entry of CGI Samples</title>
            <style>
                td {
                    width: 20%;
                    text-align: center;
                }
                input {
                    text-align: right;
                }
            </style>
    	</head>
    	<body>
    		<h1>Entry of CGI Samples</h1>
            <h2>
                <ul>
                    <li>To activate this sample, please follow the steps form the Web HOWTO in the programming guide.</li>
                    <li>Using the below redirection to test the sample CGI.</li>
                </ul>
            </h2>
    		<h2>Redirection:</h2>
    		<table width="100%">
    			<tr>
    				<td class="block_title">I/O Type</td>
    				<td class="block_title">Slot</td>
    				<td class="block_title">Channel Start</td>
    				<td class="block_title">Channel Count</td>
    				<td class="block_title"></td>
    			</tr>
    			<tr>
    				<td class="column_title">
    					<select id="iotype">
    						<option value="di.cgi">DI</option>
    						<option value="do.cgi">DO</option>
    						<option value="relay.cgi">Relay</option>
    						<option value="ai.cgi">AI</option>
    						<option value="fast_ai.cgi">Fast AI</option>
    						<option value="tc.cgi">TC</option>
    						<option value="rtd.cgi">RTD</option>
    						<option value="ao.cgi">AO</option>
    					</select>
    				</td>
    				<td class="column_title">
                        <input type=text id="slot" size="8" value="1">
    				</td>
    				<td class="column_title">
    					<input type=text id="chStart" size="8" value="0">
    				</td>
    				<td class="column_title">
    					<input type=text id="chCount" size="8" value="1">
    				</td>
    				<td class="column_title">
    					<button onclick="javascript:location.href='/cgi-bin/'
    					+iotype.options[iotype.selectedIndex].value
    					+'?slot='+document.getElementById('slot').value
    					+'&chStart='+document.getElementById('chStart').value
    					+'&chCount='+document.getElementById('chCount').value">
    						submit
    					</button>
    				</td>
    			</tr>
    		</table>
    	</body>
    </html>