[cs631apue] Arguments for cgi file
Jan Schaumann
jschauma at stevens.edu
Sun Nov 23 19:53:04 EST 2014
Chenyi Zhang <czhang42 at stevens.edu> wrote:
> When we are going to execute CGI files, do we need to think about arguments
> for cgi program?
The program will not be called with any arguments. Any data the client
wishes to send to the CGI program will need to be part of the query
string set in the environment as per RFC3875.
A trivial example can be found here:
-----
$ telnet www.cs.stevens.edu 80
Trying 155.246.89.84...
Connected to www.cs.stevens-tech.edu.
Escape character is '^]'.
GET /~jschauma/cgi-bin/env.cgi?foo=bar&blob=moo HTTP/1.1
Host: www.cs.stevens.edu
HTTP/1.1 200 OK
Date: Mon, 24 Nov 2014 01:06:15 GMT
Server: Apache/2.2.22 (Debian)
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/plain
290
GATEWAY_INTERFACE=CGI/1.1
REMOTE_ADDR=207.38.152.228
QUERY_STRING=foo=bar&blob=moo
DOCUMENT_ROOT=/var/www
REMOTE_PORT=40743
SERVER_SIGNATURE=<address>Apache/2.2.22 (Debian) Server at
www.cs.stevens.edu Port 80</address>
SCRIPT_FILENAME=/home/jschauma/cs_html/cgi-bin/env.cgi
HTTP_HOST=www.cs.stevens.edu
REQUEST_URI=/~jschauma/cgi-bin/env.cgi?foo=bar&blob=moo
SERVER_SOFTWARE=Apache/2.2.22 (Debian)
PATH=/usr/local/bin:/usr/bin:/bin
SERVER_PROTOCOL=HTTP/1.1
REQUEST_METHOD=GET
SERVER_ADDR=155.246.89.84
SERVER_ADMIN=yxiang at stevens.edu
PWD=/home/jschauma/cs_html/cgi-bin
SERVER_PORT=80
SCRIPT_NAME=/~jschauma/cgi-bin/env.cgi
SERVER_NAME=www.cs.stevens.edu
-----
The cgi script that is executed there is:
-----
#! /bin/sh
echo "Content-Type: text/plain"
echo
env
-----
-Jan
More information about the cs631apue
mailing list