The first thing you need to be able to do is to "log in" to the CS Teaching Labs computers. If you didn't bring a laptop, you can use a workstation in the tutorial room. If you did bring a laptop, or to log in from home or elsewhere later, you will need to use the "ssh" protocol for remote login.
Note that your Teaching Labs account name is the same as your UTORid. But it's the same as if by coincidence — your account is not connected to your UTORid in any other way, and for example the password is independent (although you can set it to be the same if you want).
If you haven't set your password, or you don't remember it, you can use your
UTORid credentials to set or reset your Teaching Labs password.
If you're sitting at a workstation, log in with user name account, password
account. From anywhere else, just go to
https://www.teach.cs.toronto.edu/account
The password change is instantaneous. (But do look at the output to see if
it objected to your password for not being strong enough.)
Then, you can log in. Most OSes these days have a command-line ssh program, now even including MS-Windows. The command you will use will look like this, if your account name is smithw6079:
ssh smithw6079@teach.cs.toronto.eduThere's more information on the CSC 209 web page remotelogin.html .
If you have problems logging in to your account, try consulting
items #1 and maybe 2 in
https://www.teach.cs.toronto.edu/vfaq.html
Or ask me or a TA for help.
Linux these days has all sorts of user-friendly things you can click on, but that's not what we're going to be looking at in this course. As we are discussing in this course, you can always do more from the command-line.
If you have logged in via ssh, you are already at the command line.
If you are logged in on a workstation,
you can get to a command line by running an application program called
"Terminal", whose icon
resembles an old-fashioned CRT monitor, with a '>' prompt
on it and an underline cursor.
Today's lab is about becoming familiar with the command-line environment. If this lab is trivial for you, great! Submit it and get your 1%. But I need to be sure that everyone can do this basic use of the command-line so that we can proceed with the course.
This lab also involves an even-more-trivial familiarity with the bulletin board system we will be using for asynchronous group discussion in this course.
Taking attendance is self-managed as much as possible. If you are logged in at a workstation, you can register your attendance by typing this command in a terminal window:
/u/csc209h/summer/present
If you are not logged in at a workstation, there's no way for me to tell
whether or not you are in the tutorial. In this case, please tell your
account name (UTORid) to the TA and they will mark you as present.
Then, please check that you are correctly marked as present by checking
the web page
https://wwwcgi.teach.cs.toronto.edu/~ajr/cgi-bin/auth/present
1. In /u/csc209h/summer/pub/lab/01 you will find a file named "chapter1" and a file named "chapter-one". One of these files is a text scan of the beginning of a Sherlock Holmes novel, with an error in it (because "optical character recognition" is not perfect). The other is that file corrected. But the person who did this named them poorly, and then e-mailed them to you so you lost the timestamp on the file so you don't know which is which.
Which is which?
2. This command will output all file names in the current directory which contain an 'x' in them (anywhere in the name):
echo *x*
This command will output all file names in the current directory which contain an 'x' at the beginning of the name:
echo x*
Write commands to output the following. Some of them may require a different
approach. Keep your answer as simple as possible.
(Do not worry about the issue of files whose names begin with a dot.)
a) file names containing an 'x' at the beginning and another 'x' somewhere
else in the name
b) file names containing an 'x' at the beginning and maybe another 'x'
somewhere (or maybe not —
that is, include both categories of such files)
c) file names containing an 'x' anywhere in the name
d) file names containing two 'x's in the name (anywhere)
e) file names containing both an 'x' and 'y' in the name, anywhere, in either
order
3. In /u/csc209h/summer/pub/lab/01 there are a number of identical files named [0−9], except that one of them is not identical. Which file is the odd one out?
4. How many times does the word "the" appear in the file chapter1?
What is the second-commonest word?
5 (as time permits). Experiment with that demonstration command for producing a word frequency
list. Put in one component at a time to understand what it does, i.e. first
the "tr" command, then that command piped to the next tr command, and so on.
tr -cs a-zA-Z0-9 '\012' </u/ajr/public_html/209/textbooks.html | tr A-Z a-z | sort | uniq -c | sort -n
If you have further time before the TA begins to "take up" these questions, think of variant approaches for question 3, or ways to do it better, or ways that you might be able to do it if it were a thousand files instead of ten.
This exercise MUST be done on a teach.cs computer (either on a lab workstation, or remotely using ssh or x2go). And it must be done all inside a terminal window (such as in ssh). I know you know how to create files on your own computer, and I know you know how to click on a button which says "create a file". That's not what we're doing here.
1. Create a small text file named "sample" using an editor.
2. "cat" the file, to see that you created what you thought you did.
Does it "end in the middle of a line"? If so, your session will look like
this:
$ cat sample This is a file.$with the next prompt at the end after the period there. (Your shell prompt is probably more verbose than a simple '$', but anyway, with the prompt at the end after the period there.)
3. Make the file perfect. You need to be able to use your tools precisely. No extra blank lines, but not ending in the middle of a line either. Check with 'cat'.
4. Make a copy of a computer program file you wrote for some other course, using the command-line, not an IDE (such as Wing-101 or Eclipse — DON'T use such things). (If you don't have one around, write a trivial program in the programming language of your choice... but again, without using an IDE, just a simple text editor.)
5. Modify this program slightly, without using an IDE.
6. Run the modified program, without using an IDE.
(Why not use an IDE? Well, once you get a car you might start driving everywhere, but if your destination is just across the street you're going to waste time trying to drive there instead of simply walking across the street. It is important that you are able to create and manipulate files without necessarily using an IDE. You need to be able to walk from the parking lot into the store, and you will find all sorts of other reasons to walk rather than to drive, from time to time. It's a more fundamental skill. You need both skills.)
You submit with a command like this:
submit -c csc209h -a lab01 sample gcd.pyIn this command, the "lab01" is the "assignment" name you are submitting under, and the "sample" and "gcd.py" are the files to submit. Substitute "gcd.py" with your own file name, of course.
You can submit files one at a time, or you can submit any number at once. For now, submit your two files you've done so far, to make sure you know how to do this while you're in a class with a TA.
Here is a problem (not for credit) to work on in the time remaining, and later as interest permits. There will be a video solution posted. There are further problems below which are also for credit which you almost certainly won't get to during the tutorial time so must do later in the week.
I have a puzzle game on my phone where there are 1001 different puzzles at the "hard" level. The screen on which you can select which puzzle to do next looks like this:
I keep pressing "random" and it gives me a random one of the puzzles which I haven't solved yet (but might have tried).
But that picture is from rather a while ago. I've now solved and tried
many more of the puzzles. I've copied and pasted the current "solved" and
"started" lists into the files
/u/csc209h/summer/pub/lab/01/solved and
/u/csc209h/summer/pub/lab/01/inprogress .
As you can see (how?), I've solved 957 of the 1001 puzzles.
And I've failed to solve 43 of the remaining 44.
I really want to try that one fresh one I've never tried yet, but I can't see which number it is!
Find out which puzzle number is the puzzle number from 1 to 1001 inclusive which is not listed in either list.
Note: This problem is tricky! The video will discuss its solution at some length. But see what you can do on your own first. Or in small groups.
But sometimes we want something like a print statement, most commonly in cases where in a normal programming language we would write "print" with static text (e.g. "print 'Your password has been changed.'"). Our particular choice of static text is not necessarily going to happen to be the output of any existing command.
So, there is a command for this purpose. It is called "echo", and it just prints (echoes) its arguments.
Try typing "echo hello" at the command prompt.
We can put a list of shell commands in a file and execute that list of commands. In fact, the shell input language is a complete programming language, as we will see over the next week or so.
For today, just produce a file named "story" which prints (echoes) three simple lines of text of your choosing.
Put the three "echo" commands in a file, so that you can execute the commands in that file by typing "sh story".
Experiment with this a bit.
The bulletin board is at https://bb-2022-05.teach.cs.toronto.edu/c/csc209
We also have a "test postings" bulletin board at https://bb-2022-05.teach.cs.toronto.edu/c/csc209test
If you have something you want to post on the bulletin board already, great! Please do so. Otherwise, if you are just posting to get this grading point, or you are posting a test message, please be sure to post in the "test postings" bulletin board. A test posting in the main bulletin board will not get the point.
When you are looking at your message in your web browser, you will be on a URL which looks like: https://bb-2022-05.teach.cs.toronto.edu/t/test-message/3
Copy and paste this URL into a text file named "post", which we will use to verify that you posted something.
You can check which files have been submitted with the command
submit -c csc209h -a lab01 -l(that's minus 'l' for "list", not a 'one')
To submit files, first of all I suggest checking that your files do contain
what you think they contain by using the "cat" command.
Expected files for lab 01 are:
Normally the 'submit' system won't let you submit files under the wrong file name, but for lab 01 I couldn't configure it that way because I don't know what your computer program file will be called. So please check the file names, and e-mail me with any problems.
The deadline for each lab in this course is the end of Friday (midnight). In this case that would be the end of Friday May 13. Late submissions are not accepted without a good reason and a written explanation (but if you are late, DO submit it immediately, then e-mail me the explanation).
You can submit files at any time before the due time, and you can submit them in a group as above or individually. You can resubmit a file by using the −f option, e.g.
submit -c csc209h -a lab01 -f story
If there are any problems with this, send e-mail. Problems running the 'submit' command will not generally be accepted as a reason for lateness.
As mentioned in part 3 above, there is a tutorial attendance requirement to get the marks for the lab. Please make sure that you have got your attendance registered during the tutorial time, either by typing the 'present' command on the console of a lab workstation, or with the TA.
The lab work in this course is individual. You can discuss the items which are not for course credit with anyone, but the items which are submitted for course credit must represent your own work. It is also an offence to assist others in committing an academic offence (e.g. by providing your solution to them).
If you have questions about work to be submitted for course credit, ask a TA or the instructor (perhaps by e-mail). More information at the end of the course information sheet.