How to write a CGI for the Apache Web server in C



Similar documents
People Data and the Web Forms and CGI CGI. Facilitating interactive web applications

CGI An Example. CGI Model (Pieces)

People Data and the Web Forms and CGI. HTML forms. A user interface to CGI applications

10. Java Servelet. Introduction

How to use the Eclipse IDE for Java Application Development

at () in C:\wamp\www\icaatom-1.2.0\icaatom \plugins\sfLucenePlugin\lib\vendor\Zend\Search\Lucene\Document.php line

INTRUSION DETECTION AND PREVENTION SYSTEM: CGI ATTACKS. A Thesis. Presented to. The Faculty of the Department of Computer Science

Chapter 27 Hypertext Transfer Protocol

CGI Programming on the World Wide Web

Web Services April 21st, 2009 with Hunter Pitelka

7 Why Use Perl for CGI?

Forms, CGI Objectives. HTML forms. Form example. Form example...

Chapter 8. Forms and Form Processing

1 Recommended Readings. 2 Resources Required. 3 Compiling and Running on Linux

User Interface Design using CGI Programming and Boa Web Server on M5249C3 Board

Hands-on Hacking Unlimited

WebObjects Deployment Guide Using JavaMonitor. (Legacy)

To connect to the cluster, simply use a SSH or SFTP client to connect to:

INT322. By the end of this week you will: (1)understand the interaction between a browser, web server, web script, interpreter, and database server.

Apache and Virtual Hosts Exercises

Dispatcher. PDF Generated : :40:15.

CGI PROGRAMMING nd Edition. Perl for the World Wide Web by JACQUELINE D. HAMILTON

Embedded Software Development

Secure Shell. The Protocol

USING CGI WITH LABVIEW

Updating MNS-BB CUSTOMER SUPPORT INFORMATION PK012906

Implementation of Embedded Web server using TEA algorithm

USING MOBILE PHONES FOR MOBILE LEARNING: EVALUATION OF HISTOBRICK

Andreas Burghart 6 October 2014 v1.0

Binary Upgrade Procedure

Adding web interfaces to complex scientific computer models brings the following benefits:

Solr Bridge Search Installation Guide

CSC230 Getting Starting in C. Tyler Bletsch

AVR32737: AVR32 AP7 Linux Getting Started. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

Version 1.0. File System. Network Settings

User Manual of the Pre-built Ubuntu Virutal Machine

Interfacing the Apache Web Server to APLX

Setting up an Apache Web Server for Greenstone 2 Walkthrough

Quick Start Guide Joomla!: Guidelines for installation and setup. Why Joomla!

Internet Technologies. World Wide Web (WWW) Proxy Server Network Address Translator (NAT)

Introduction to the. Barracuda Embedded Web-Server

Software Development Tools for Embedded Systems. Hesen Zhang

EDS1100/2100. VMware Image for Linux Software Developers Kit (SDK) Quick Start Guide

Getting started with ARM-Linux

Intel Storage System SSR212CC Enclosure Management Software Installation Guide For Red Hat* Enterprise Linux

File Transfer Examples. Running commands on other computers and transferring files between computers

8/9/16. Server-Side Web Programming Intro. The Hamburger Model. To make a Web server based program

Cosmic Board for phycore AM335x System on Module and Carrier Board. Application Development User Manual

Buildroot for Vortex86EX (2016/04/20)

INSTALLING KAAZING WEBSOCKET GATEWAY - HTML5 EDITION ON AN AMAZON EC2 CLOUD SERVER

WEB2CS INSTALLATION GUIDE

Authenticate vsftpd (a secure FTP server for UNIXlike systems) with IDENTIKEY Authentication Sever

APPLICATION NOTE. How to build pylon applications for ARM

Access to HZB internal computers via SSH tunnel with PuTTY (Screenshots Windows 7)

Addressing Application Layer Attacks with Mod Security

WWA FTP/SFTP CONNECTION GUIDE KNOW HOW TO CONNECT TO WWA USING FTP/SFTP

First Steps. Remote Access Gateway IGW/922. with DIL/NetPC ADNP/9200

WebObjects Deployment Guide Using JavaMonitor

CP Lab 2: Writing programs for simple arithmetic problems

Tips for getting started! with! Virtual Data Center!

SparkLab May 2015 An Introduction to

An Embedded Wireless Mini-Server with Database Support

Updating MNS-6K software on Magnum 6K Switches

Secure Web Programming

APACHE WEB SERVER. Andri Mirzal, PhD N

Exercises: FreeBSD: Apache and SSL: pre SANOG VI Workshop

1. When will an IP process drop a datagram? 2. When will an IP process fragment a datagram? 3. When will a TCP process drop a segment?

User Manual of the Pre-built Ubuntu 9 Virutal Machine

Virtual Host (Web Server)

Web Server for Embedded Systems

CSCE 665: Lab Basics. Virtual Machine. Guofei Gu

Omnistar Recruiter Install User Guide (Codelock)

Apache HTTP Server. Implementation Guide. (Version 5.7) Copyright 2013 Deepnet Security Limited

Brocade Certified Layer 4-7 Professional Version: Demo. Page <<1/8>>

REQUIREMENTS AND INSTALLATION OF THE NEFSIS DEDICATED SERVER

Installing buzztouch Self Hosted

Network Technologies

Introduction. dnotify

DEPLOYMENT OF I M INTOUCH (IIT) IN TYPICAL NETWORK ENVIRONMENTS. Single Computer running I m InTouch with a DSL or Cable Modem Internet Connection

ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters

Upgrade your Software


App Note. VoxStack GSM Gateway API

CycleServer Grid Engine Support Install Guide. version 1.25

mod_security the web application firewall

Table of Contents. Java CGI HOWTO

CGI-based applications for distributed embedded systems for monitoring temperature and humidity

Avaya Media Server Monitoring and Management. David Lover Chief Strategy and Technology Officer, Cross

Networks and Protocols Course: International University Bremen Date: Dr. Jürgen Schönwälder Deadline:

How to install PowerChute Network Shutdown on VMware ESXi 3.5, 4.0 and 4.1

Moxa Device Manager 2.3 User s Manual

Transcription:

How to write a CGI for the Apache Web server in C The Com/PC Embedded Gateway Linux (EGL/2) operating system comes with a pre-installed Apache Web server. Please see also mht-cpc1l-07.pdf: How to use the Apache Web server for more information. This server supports also CGI (Common Gateway Interface). 1. Step: Download the file cgi-demo.c from the Com/PC website at www.ssv-comm.de. This file is the C source code for a simple CGI sample. 2. Step: Run your SSV colinux environment on your development PC. Translate cgi-demo.c to an executable. Use the following command line gcc o cgi-demo cgi.demo.c within the SSV colinux environment. This command line runs the GNU C compiler and creates the executable cgi-demo. 3. Step: Transfer the executable cgi-demo from the colinux directory to the Windows directory /windows/transfer. Then run a TFTP server within the Windows environment. SSV EMBEDDED SYSTEMS 2007, mht-cpc1l-010.doc, Rev. 1.00. 1

4. Step: Run a Telnet or SSH session. Then execute the following commands: cd /rwnv/opt/lampp/cgi-bin tftp binary connect 192.168.0.2 get cgi-demo quit chmod +x cgi-demo Please note: This sample assumes that your development PC with Windows and colinux is using the IP address 192.168.0.2. Change this address if necessary. 5. Step: Access the executable cgi-demo with your Web browser. The URL for this CGI on the Com/PC is: http://192.168.0.126/cgi-bin/cgi-demo SSV EMBEDDED SYSTEMS 2007, mht-cpc1l-010.doc, Rev. 1.00. 2

This URL assumes that your Com/PC is using the IP address 192.168.0.126. Change this address if necessary. The cgi-demo.c source code: // cgi-demo.c: Simple CGI demo program. // Vers. 2.00-04.April 2007 // k.d.walter@t-online.de // Includes #include <stdio.h> #include <stdlib.h> #include <string.h> int main (int argc, char *argv[]) { char *penvptr; printf ("Content-type: text/html\n"); printf ("\n"); printf ("<HTML>\n"); printf ("<HEAD>\n"); printf ("<TITLE>CGI Environment Variable</TITLE>\n"); printf ("</HEAD>\n"); printf ("<BODY>\n"); // SERVER_SOFTWARE penvptr= getenv ("SERVER_SOFTWARE"); printf ("SERVER_SOFTWARE= "); // SERVER_NAME penvptr= getenv ("SERVER_NAME"); printf ("SERVER_NAME= "); // SERVER_PROTOCOL penvptr= getenv ("SERVER_PROTOCOL"); printf ("SERVER_PROTOCOL= "); SSV EMBEDDED SYSTEMS 2007, mht-cpc1l-010.doc, Rev. 1.00. 3

// SERVER_PORT penvptr= getenv ("SERVER_PORT"); printf ("SERVER_PORT= "); // REQUEST_URI penvptr= getenv ("REQUEST_URI"); printf ("REQUEST_URI= "); // REQUEST_METHOD penvptr= getenv ("REQUEST_METHOD"); printf ("REQUEST_METHOD= "); // GATEWAY_INTERFACE penvptr= getenv ("GATEWAY_INTERFACE"); printf ("GATEWAY_INTERFACE= "); // HTTP_CONNECTION penvptr= getenv ("HTTP_CONNECTION"); printf ("HTTP_CONNECTION= "); // PATH_INFO penvptr= getenv ("PATH_INFO"); printf ("PATH_INFO= "); // PATH_TRANSLATED SSV EMBEDDED SYSTEMS 2007, mht-cpc1l-010.doc, Rev. 1.00. 4

penvptr= getenv ("PATH_TRANSLATED"); printf ("PATH_TRANSLATED= "); // REMOTE_HOST penvptr= getenv ("REMOTE_HOST"); printf ("REMOTE_HOST= "); // REMOTE_ADDR penvptr= getenv ("REMOTE_ADDR"); printf ("REMOTE_ADDR= "); // REMOTE_PORT penvptr= getenv ("REMOTE_PORT"); printf ("REMOTE_PORT= "); // REMOTE_IDENT penvptr= getenv ("REMOTE_IDENT"); printf ("REMOTE_IDENT= "); // SCRIPT_FILENAME penvptr= getenv ("SCRIPT_FILENAME"); printf ("SCRIPT_FILENAME= "); // SCRIPT_NAME SSV EMBEDDED SYSTEMS 2007, mht-cpc1l-010.doc, Rev. 1.00. 5

penvptr= getenv ("SCRIPT_NAME"); printf ("SCRIPT_NAME= "); // QUERY_STRING penvptr= getenv ("QUERY_STRING"); printf ("QUERY_STRING= "); // CONTENT_TYPE penvptr= getenv ("CONTENT_TYPE"); printf ("CONTENT_TYPE= "); // CONTENT_LENGTH penvptr= getenv ("CONTENT_LENGTH"); printf ("CONTENT_LENGTH= "); } printf ("</BODY>\n"); printf ("</HTML>\n"); return (EXIT_SUCCESS); That is all. SSV EMBEDDED SYSTEMS 2007, mht-cpc1l-010.doc, Rev. 1.00. 6