#Set an output line using CGI and bash scripting

<span class="abstract">This articles shows how to write a simple CGI to set via Web an output line</span>

##The setbits command

By default it is available on the FOX Board the command <b>setbits</b> that allows the control of each general purpose output line. 

The syntax of this commad is:

<pre class="minicom">
setbits [OPTIONS]
</pre>

Where OPTIONS are:

<pre class="minicom">
-p port   Which port to use, valid values are a,b or g
-b bit    Bit number to change
-s state  Change selected bit to state (0/1)
</pre>

For example with setbit command it is possible to turn on the RED led DL1 on the FOX Board (see
the [FOX pinout](/18) to locate it). This LED turn on when the line 3 of the port A
goes low.

To turn on red led DL1 type:

<pre class="minicom">
# <b>setbits -p a -b 3 -s 0</b>
</pre>

To turn off red led DL1 type:

<pre class="minicom">
# <b>setbits -p a -b 3 -s 1</b>
</pre>

To execute these commands remotely via web use this CGI:

@source='./ioline.sh'

Save it in the cgi folder (see @h1='209') and call it from your browser using these URLs:

<ul>
<li>DL1 On <a href="http://192.168.0.90/cgi/ioline.sh?port=a&line=3&state=0">http://192.168.0.90/cgi/ioline.sh?port=a&line=3&state=0</a></li>
<li>DL1 Off <a href="http://192.168.0.90/cgi/ioline.sh?port=a&line=3&state=1">http://192.168.0.90/cgi/ioline.sh?port=a&line=3&state=1</a></li>
</ul>

