|
|
|
I/O Via the Standard Streams
Stdin - Standard InputRequest methods such as HTTP POST and PUT have attached information in the request body that, unlike the common script parameters, is not present as environment variables. This information, CONTENT_LENGTH bytes in total, is instead available for reading from stdin. See also the previous page on environment variables. Stdout - Standard OutputIt is up to your script to write out whatever HTTP response headers it needs to stdout. After the headers (possibly none), the script must produce two newlines, and whatever is written after that ends up in the request body as the webpage seen by the client. Stderr - Standard ErrorBasically, your CGI script talks to the world through stdout and to the logs via stderr. By default, stderr is sent to the main server log, but this may be altered by the server administrator. Your debug and/or logging messages should typically end up on stderr. When your roxen process was started with the --once flag, all stderr output ends up in the console from which roxen was started. An example script in /bin/sh exemplifying all of the above might look like this: #!/bin/shif [ -z "$CONTENT_LENGTH" ]; then cat << end_form Content-type: text/html <form method=post> <input type=text name=variable size=40 value="Press submit to see a POST request body."> <input type=submit> </form> end_form else cat << end_reply Content-type: text/plain $CONTENT_LENGTH bytes of data were sent to us. The content-type was $CONTENT_TYPE: end_reply cat fi echo "CGI example ran at `date`." 1>&2 |
|||||||||||