Enable CGI on foXServe and Remote I/O control with HTML and CGI
This article illustrates how to write a cgi in C to generate a web page to control remotely each I/O line available on J6 and J7 extension sockets.
On foXServe I/O control can also be performed from PHP scripting.

The original article on ACME website http://www.acmesystems.it/?id=212 demostrate the use of BOA for CGI execution, in this page we will enable CGI on apache.

Enable CGI execution under APACHE WEBSERVER

Connect to your foXServe shell and create the directory cgi-bin
mkdir -p /mnt/flash/root/cgi-bin
edit /etc/httpd.conf

Find this line.

#ScriptAlias /cgi-bin/ @@ServerRoot@@/cgi-bin/

Change it to read as follows, but of course substitute the full unix path to the directory containing your scripts if it is different than what is shown below.
ScriptAlias /cgi-bin/ /mnt/flash/root/cgi-bin
Then, track down this line:
#AddHandler cgi-script .cgi
and make it read as follows (uncomment it):
AddHandler cgi-script .cgi

Next, append on the end of the file a per directory directive

<Directory /mnt/flash/root/cgi-bin>
  AllowOverride None
  Options None
</Directory>


Now download the cgi executable iocontrol.cgi and upload it using FTP ot scp inside the newly cretaed cgi-bin folder.
Don't forget to give the right permissions to the file with the command:

chmod 0777 /mnt/flash/root/iocontrol.cgi

point your browser to http://<ip of your foxserve>/cgi-bin/iocontrol.cgi and an output like this should appear:



You can also compile the C source code iocontrol.c with Webcompiler or inside the SDK:
o How to compile a C program with WebCompiler
o How to compile a C application
* Rename the executable file in iocontrol.cgi and save it in the cgi folder
* Access to the cgi web page from this URL:
o http://<your ip>/cgi-bin/iocontrol.cgi

The web page shown different I/O sections:

* Lines A0-A7 (configurable as input or output)
* Lines B0-B7 (configurable as input or output)
* Lines IOG8-IOG15 (configurable as a block of all input or all output)
* Lines IOG16-IOG23 (configurable as a block of all input or all output)
* Lines IOG0 and IOG24 (configurable as input or output)
* Lines IG1-IG7 and IG25-IG31 (fixed as input)
* Lines OG1-OG7 and OG25-OG31 (fixed as output)

For each block there is the line name, the physical pin on J6 or J7 and some buttons to set (3.3 volt) or clear (0 volt) the line and configure it as input or output when applicable.

On every refresh of this page the state (HI or LO) of each input line is updated.