Using CGIFILE

CGIFILE uses a template and ACTION like CGIEMAIL, but appends information to a file rather than mailing it. These directions assume that you have already created a web page form and template file using CGIEMAIL. If not, please review the CGIEMAIL documentation for directions on how to create these files.

CGIFILE requires a file called "incoming.txt". The incoming.txt file stores the responses submitted by the form in the format specified in the template file.

Overview

  1. Visitors enter information into a web page form.
    In this example, the web page form is called feedback.htm

  2. The information is stored into a file called "incoming.txt"
    NOTE: This file must be called incoming.txt and must reside in the same location as the template file.

  3. A template file describes how the responses will be listed in the "incoming.txt" file.
    In this example, the template file is called feedback.txt

CGIFILE Directions

  1. Login to a host such as apollo or online using Telnet
  2. Using the Change Directory command (cd), change directory to public_html

    cd public_html

  3. Using the "mkdir" command, create a directory inside public_html.
    This directory will be used to store the web page form, template file and incoming.txt file. Later, we will give this directory write access so data can be written to the incoming.txt file. These files need to stored in it's own directory to restric t write access to only this directory and to avoid giving users access to write to your other files.

    In this example, we will create a directory called "feedback".

    Example:

    mkdir feedback

  4. Copy the CGIEMAIL web page form and template file you created earlier into the new directory.

    Example:
    Using the CGIEMAIL example, move the web page form "feedback.htm" and template file "feedback.txt" stored in the public_html directory to the new directory "feedback". This will need to be done in two steps.

    Step 1: cp feedback.htm feedback

    Step 2: cp feedback.txt feedback

  5. Change file permissions to permit writing to this directory by anyone.

    Example:

    fs setacl feedback system:anyuser rwl

  6. Using the change directory command (cd), change to the directory storing your files

    Example:

    cd feedback

  7. Using "pico", edit the template file to use CGIFILE instead of CGIEMAIL by deleting the mail information. (To:, From: and Subject:).

    Example:
    In the CGIEMAIL example, the template file is called "feedback.txt".

    pico -w feedback.txt

    The contents of the cgiemail template file look like this. The results are listed below with headings so the e-mail will be readable.:

    From: [email] (optional)
    To: userid@sfsu.edu
    Subject: Sample Questionnaire

    Student: [student]
    Term: [term]
    Major: [major]
    My comments: [comments]

    Change the cgifile template file to look like this. The results here are shown without headings -- the data is comma delimited with a single carriage return at the end of the line so it can easily be imported to another program.:

    [email],[student],[term],[major],[comments]

  8. Save the changes and exit by pressing CTRL and X at the same time, say yes when prompted to save.

  9. Using "pico", edit the FORM tag in the web page form to point to CGIFILE instead of CGIEMAIL.

    Example:
    In the CGIEMAIL example, the web page form is called "feedback.htm".

    apollo% pico -w feedback.htm

    Using the down arrow key, scroll down until you see code similar to the following:

    <form METHOD="POST" ACTION=""[servername]/cgi- bin/cgiemail/~accountname/feedback.txt">

    Edit the FORM tag to point to CGIFILE:

    <form METHOD="POST" ACTION="[servername]/cgi-bin/cgifile/~accountname/feedback/feedback.txt">

    Also, check the following:

  10. Using the "touch" command, create an empty "incoming.txt" file in the feedback directory.
    The incoming.txt file stores the responses submitted from the form into a format specified in the template file.

    Example:

    touch incoming.txt

  11. Test the web page and make sure it puts the responses into the incoming.txt file.

  12. If you want to clear the information in the incoming.txt file, use the Remove (rm) command to delete the file then use the touch command to create it again

    Example:

    Step 1: rm incoming.txt

    Step 2: touch incoming.txt

To pickup the results/data from your form you can ftp incoming.txt to your workstation/PC.


SFSU Home   Search   Need Help?  

1600 Holloway Avenue, San Francisco, CA 94132 (415) 338-1111
Last modified February 11, 2008 by the Web Team