![]() |
![]() Fall Semester 2009 |
a) we know what it takes to write a program in
|
1. log into silo 2. go into a folder (create one if necessary) 3. create a file (using pico -- no extension needed)
3.1 the first line in the file reads4. make the file executable with chmod 700 or chmod u+x
5. run the file with
| |
| b) we also know a bit of | |
| |
Equivalent lines (lines with the same effect):
If "age" is a variable whose value has been read as above:
c) web scripts need to respect the HTTP format in their output; thus
This can be summarized by saying that
With this header the program promises to print HTML (as the browser typically expects)."Content-type: text/html\n\n" d) any CGI script is being passed input data in a format like this: Here one paramhttp://silo.cs.indiana.edu:8346/cgi-bin/whatever?day=monday
Two params ("age" and "name") are being passed to script one.http://silo.cs.indiana.edu:8346/cgi-bin/one?age=9&name=adrian The age value is "9" (a string) and the name is "adrian" (also string). e) finally, a web script can use a specialized library to read the incoming data:
With this we wrote a program that acts like this:
That is, the program collects name and age then calculates and prints a report.Welcome to the program. What's your name: Adrian How old are you: 9 Well Adrian next year you will be 10 years old Here's the script written in Python:
f) any script can use an HTML form to have the data collected and sent its way:
This is HTML document tomato.html collecting "name" and "age" for "whatever". Challenge One. Implement a script that
Here's a model for it (not much help, I am sure).
So we need to do this, but on the web. Write a web script with this behaviour.
Updated by Adrian German for A202/A598, A290/A590 and A348/A548 | |