We start with this minute paper: Using the language of your choice write a program that asks the user about the name and age of the user. The program then prints a report saying how old the user will be next year. Example: program> Welcome to this program. What is your name: ... (e.g., Larry Bird) then press return How old are you: ... (e.g., 56) then press return Well, Larry Bird, next tyear you will be 57. Then the program ends. I need a paper with what you can write in 5 minutes. http://www.cs.indiana.edu/classes/a348 Sequence of steps: 1. Log into silo 2. Go to a certain folder: ~/09101300 mkdir ~/09101300 cd ~/09101300 3. Create a file with the program: pico one 4. Simplest content: #!/usr/bin/perl print "Howdy.\n"; In Python: #!/usr/bin/python print "Howdy" 5. Run the program: ./one Works only if you make it executable first: chmod +x one These steps work for all programs. Know them. Solution to the minute paper: -bash-3.2$ ls -ld two -rwx------ 1 dgerman faculty 226 Sep 10 13:35 two -bash-3.2$ cat two #!/usr/bin/python print "Welcome to the program." name = raw_input("What's your name: ") age = raw_input("How old are you: ") print "Well", print name, print "next year you will be", print int(age) + 1, print "years old" -bash-3.2$ ./two Welcome to the program. What's your name: Adrian How old are you: 9 Well Adrian next year you will be 10 years old -bash-3.2$ In Perl it's almost the same minus some details: -bash-3.2$ ls -ld one -rwx------ 1 dgerman faculty 303 Sep 10 13:51 one -bash-3.2$ cat one #!/usr/bin/perl print "Welcome to the program.\n"; # name = raw_input("What's your name: "); print "What's your name: "; $name = ; chop($name); print "How old are you: "; $age = ; print "Well "; print $name; print " next year you will be "; print $age + 1; print " years old\n"; -bash-3.2$ ./one Welcome to the program. What's your name: Adrian How old are you: 9 Well Adrian next year you will be 10 years old -bash-3.2$ Task: write a web script with the same behavior. Steps: 1. Go into cgi-bin 2. Develop a program there 3. Input: use a form or do it differently. http://silo.cs.indiana.edu:8346/cgi-bin/09101300/one?name=Larry&age=13 -bash-3.2$ pwd /u/dgerman/apache/cgi-bin/09101300 -bash-3.2$ ls -ld * -rwx------ 1 dgerman faculty 234 Sep 10 14:12 one -bash-3.2$ cat one #!/usr/bin/perl use CGI; $input = new CGI; print "Content-type: text/html\n\n"; $name = $input->param("name"); $age = $input->param("age"); print "Well ", $name, " you will be ", $age + 1, " years old next year."; -bash-3.2$ In lab: a) do this in Python b) use forms for the user interface c) ask a harder problem and try solve it See you in lab later today and tomorrow!