CSc 315, Lab. 2
Due by Wednesday 24 January 2007
Pat has now set up your account on osiris, this server. Your account
code is the same as in the linux lab. Your password is also the same,
or you have been given a temporary password, which you must change
today (see server instructions below.) You can proceed to
put your html file(s) on osiris, so you have a web page accessible from
anywhere. As the course progresses, you will be adding features to your
pages.
Also today, you will add a table and a form to your pages, and start
thinking about learning to program in perl.
Telling a story
Everybody has some story to tell, about themselves, about some group
they are involved with about their family or home town. Your homework
for the weekend is to gather together some pictures and plan a set of
pages telling your story. You could start with a picture of yourself,
or art work you have created. You will need to link all your pages
together. Your main page will need to be named index.html .
"Your" page
The end result of your work in this course will be an internet page (or
several pages, linked together) that either presents you, or an
organization
you would like to present, to the world. Your combined work also
will
show off the creativity, interests, and diversity of Bishop's students.
So give some thought to what you have to say, and gather up a few
photographs
or drawings you want to include.
Instructions
In the lab, the goals are:
- To add a table to your page.
- To add a form to your page (The form inputs could be within a
table, in fact.)
- To put your html page on osiris, now that your account has been
set up. You will learn to use 2 standard internet services:
- sftp or scp - (Secure) File transfer protocol,
or secure copy, to get your file to osiris
- ssh (secure version of telnet) - allows you to log on
to a remote computer and execute comands. It emulates a vt100 terminal.
Please note: UNIX is case sensitive! Both user names
and file names must be typed in the correct case. Lower case is the
most usual.
Tables:
Tables are a good way of formatting information that fits logically
into cells of a row/column arrangement. They are quite flexible, with a
number of different options. One interesting one is "spanning" where a
cell may
span more than one row
or column. All tags are in pairs, like <table>
</table> which delimits a table. Within a table there
are rows, within a row
there are Detail items. Within the detail item is the cell's contents.
The
tags are: (an example follows)
<table> - defines a table. May have border, padding, etc.
<tr> - delimits a row
<td> - defines a cell, with its contents
<table border=1>
<tr> <td> Name </td> <td colspan=2 align=center> Phones </td> </tr>
<tr> <td> Spiderman </td> <td> 822-9600 </td> <td> 911 </td> </tr>
</table>
This will look like:
Name |
Phones |
Spiderman |
822-9600 |
911 |
Forms:
A form is the logica unit of information that is transferred to
an action (a URL, usually a CGI program, but could also be
mailto:
...), using a method of get or post. ["HTML
quick reference" is the guide you will need to refer to. -- It is gone,
see the substitute linked from the outline.] The form
ends,
as usual, with a </form> tag. Within it, there can be
any normal
HTML, and also the following value-producing tags:
- <input ...> no ending tag, which has type,
name,
and gets a
value. An initial value can be given. The valid types are:
- "text" (the default), may also have size
and maxlength
- "password" - like text but shows stars
- "checkbox"
- "radio" - only one radio button of the same name may
be
selected
- "submit", "reset" - buttons. Value is
displayed
on the
button
- "hidden" - value is passed back to the server
- <select> <option> .... </select> a
select list.
- <textarea rows= cols= > default text
</textarea>
Step by step for using the server:
In these instructions, things you click on with the mouse
are shown bold, things you type in are shown in "tty"
font. Some alternate instructions are provided for use away from
the lab, were you may not have the same desktop or utilities as in
Bishop's labs. We are assuming you have the same account name on both
systems. Otherwise, you'll have to connect to myothername@osiris
- Modify your web page you started last class (or make a new one)
to include a table and a form.
- Use scp (or sftp) to transfer your file(s) to
osiris. Don't forget any images.:
- scp index.html
osiris:public_html
and give your password when asked
- To use command - line sftp (This
is sometimes more convenient when you have several files to transfer}
- cd to the directory in which your
file is located, if necessary.
- type: sftp osiris.ubishops.ca
this opens a connection to osiris (at Bishop's, you may always shorten
osiris.ubishops.ca to osiris)
- you must now give your password for osiris
- type cd public_html to change to your public
subdirectory for web pages.
- type: put index.html
this sends the file index.html to osiris
- type: dir
to see that it is there. Notice the case of file
name. Unix file names are case sensitive, so you will have to refer to
it exactly as it appears.
- type: bye to get out of sftp
- Check that it is there, using any browser. Your
address depends on your login name. For the login name "astudent", the
address is: http://osiris.ubishops.ca/~astudent You won't be
able to see anything but a not found message until
you have a file named index.html, unless you add a
specific
file name (after another / ) you will see that file instead. index.html
should contain links to any other files you have. You will only
be
graded upon files that are linked from index.html.
- Start a terminal, and start a ssh session on osiris: (see Putty instructions
if you have windows at home.)
ssh osiris
- You should be asked for your password. If you
do not in
fact have an account, see Pat.
- passwd
-- if you should want to change your password
- cd public_html Change to your public
directory
- ls
List your directory. (Unix commands
are
very short)
ls
-l
Check the permissions. Should be -rw-r--r--
- While in the terminal session, you can edit files with either nano or vi
- Test your html file from the location: http://osiris.ubishops.ca/~<youracct>
- Fill in your form, and click on the submit button. Look at the
query results. Make sure you see something!
What to do today:
- Have a
set of pages, linked together, that tell some kind of story: About
yourself, about a group, about a company you run, or imagine. (If you
invent a fictious organization, be sure to put a disclaimer, saying
that this is a student project, and that "Space vacations.com" is not
an operating company.)
- Add a table of your own
design. Make it interesting and related
to you in
some way. This could be your brothers and sisters, info about
schools
you attended, etc.
- Make sure that you have one page with the file name index.html,
then be sure that it always contains links to your other pages (use a
relative
link, i.e. just the file name.)
- Construct a form on your
main page or another page, to gather
some
information for the story you are telling. For instance, it could be a
guestbook entry, an order form
for a selection of books, or a quiz on some subject. A form must have a
submit button and should also have a reset button. Use a reasonable
variety
of ways of gathering data. In fact, please use 4 out of these five:
- input (or password)
- checkbox
- radio button
- select list
- textarea
- Test the working of your form by specifing as action:
- "http://osiris.ubishops.ca/~jensen/perl/echo.pl"
- "/~jensen/perl/echo.pl"
is acceptable for short, as both pages are on osiris.
- [By Friday, practice
writing
a perl program.] It should prompt for and accept some input,
and calculate some results. Include an "if" test and a loop, at least. Picking up Perl is a
freely redistributable tutorial, you can use as well as the textbook.
See also my sample Perl program.
Suppose your program is called first.pl
You can run it by typing either:
- perl first.pl
- ./first.pl --
providing you made it executable, and the first line says #!/usr/bin/perl
- Submit your perl program using submit csc315 ...
Please notice that spaces and special characters are specially
encoded in your form data. Also notice that the data comes in
name,value pairs, with some special
characters as separators. What are they? (This is why special
characters
in the data need to be encoded.)
Things to check for:
- Your page contains your name, and something about you. I always
refer
graduate schools and future employers to your student page!
- your file, when it gets to the server, is named index.html
- otherwise, I won't be able to find it to give you
credit.
- Your submit works, you get results back from your form, once it
is on osiris.
This lab is complete when you have submitted a perl program, and
you have a working form on osiris, that I can
find by typing http://osiris.ubishops.ca/~youracct
You have finished "lab 2".
Prepared by Lin
Jensen , 2 May 2000. Updated 23 January 2007
What to do if you are stuck with a windows machine:
Start putty in ssh mode (not telnet). putty.exe
is a client for the telnet and ssh protocols. Putty is open source, GPL
licensed software. This means you may copy and use it, but may never
sell it. A copy that runs under windows is in R:\csc315.a09\read, you
can drag its icon to the desktop to create a
shortcut. You may also make a copy to take home or download one for
your Mac,
etc. from the internet.
- Click on the desktop icon to start putty.
- In the connect menu, choose ssh. The system you
want is osiris.ubishops.ca You don't want to change anything
else.
- You will see a "login:" prompt. Type your login name (case
sensitive), and press enter.
- Contunue with the regular lab instructions
Using WinSCP (At Bishop's) [Can also be copied
from R:...CSC315.A09/READ to take home]
- Double click on the WinSCP icon
- Type osiris.ubishops.ca in the host field,
also your name and password.
- [At home, you can "Save" this session info.]
- Click on "Connect"
- You will eventually see two directory listings. On the left is
your local machine (the one you are sitting at). Change directory to
the one where your file is located.
- Change to the subdirectory on osiris named: public_html. This
is your "public" directory, where you will put all your web pages, and
cgi scripts.
- There are "radio buttons" labeled "ASCII" and "Binary." It is
important to select ASCII. (Binary is used for non-text files,
such as pictures or executable programs.) This is because text files
under windows have a CR at the end of each line, which must be removed.
- Select your file(s) and drag into the right-hand window, or Click
on the arrow pointing right. Your file should now appear in the
remote (osiris) directory window, on the right. It should be several
bytes shorter than the original, this is because Unix stores new lines
differently.
- Verify that the name is what you want, beware that Unix is case
sensitive. You may rename it using SCP, or in your telnet session.
- Exit WinSCP. You are now ready for the next step.