Thread: CGI program help please

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    34

    CGI program help please

    I'm having a hard time trying to figure out how to implement this.

    Develop a program written in C that will handle encoding and decoding of
    CGI data.

    * Your program should run from a command-line interface in Linux (preferably)
    or DOS. It should prompt the user to enter these items:
    1. Name
    2. Address
    3. Phone number

    * Once you collect this data, CGI encode it and display the encoded string.

    * Decode the CGI data, and display a label and associated value (these should
    match exactly what the user entered.)

    * Do not link in or use any code except what can be found in the standard
    libraries.

    Now I can set up and make a program that will fulfill the data requirements with executable that a user runs, though I'm not sure how to convert it to CGI and display it from there. I can also make the CGI script so that if the user goes to a webpage, puts in the information in the requirements will be fulfilled. My problem is how do I encode and decode data as CGI from a command line or shell, and how can data from an executable be made into CGI data. Thanks.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    So have you read any pages on the web as to how CGI works ?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    34
    I've read quite a bit of information on CGI encoding, and how it works. A quick run-down from what I've learned.

    A CGI is a program that automatically runs when a user goes to a website address, or clicks a link to run the program such as something that says "click here to see the current time". The server then executes the CGI program, and the results are displayed on the user's web browser.

    My problem is understanding how a program is suppose to executed on a command line, if it is run exclusively server-side, with results in a web browser. (how I even open a web browser from a command line is something I've not been able to determine).

    I posted the same question on another website, and a post someone made made me think about the problem a bit differently. I think the problem is that I'm not suppose to create a CGI script, but rather use URL encoding and decoding methods to take care of the data that the user inputs. Does this sound more reasonable?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Yes, it seems to me like it's just an exercise in encoding and decoding a CGI request. I don't think you need to actually send it to a remote server or anything.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  2. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  3. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  4. Replies: 2
    Last Post: 05-10-2002, 04:16 PM
  5. redirection program help needed??
    By Unregistered in forum Linux Programming
    Replies: 0
    Last Post: 04-17-2002, 05:50 AM