Unformatted Document Excerpt
Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
10: EECS Assignment 1
September 26, 2008
Due Monday 6 Oct 2008 at 12:00pm (noon)
1 Login to your Unix account
For this class, you will be doing your assignments by logging on to a shared machine (server) running the Unix
operating system. Even though you may be using a personal computer or a workstation that is capable of computation
locally, you will mainly be using them as terminals (clients), whose job is to pass keystrokes to the server and display
outputs from the server.
To use a shared machine, rst you need an account on the machine. EECS support has created an account for each
student. To retrieve the username and password go to the following website:
The website asks for your UCInetID and the according password before giving you the account information of your
new EECS account. Note that your browser may also ask you to accept a certicate to open the secure website. DO
NOT contact NACS directly. We are NOT using NACS unix machines for EECS 10. If you have a problem please
contact your EECS 10 TA, (firstname.lastname@example.org).
The name of the instructional server is malibu.eecs.uci.edu. You can log into your account with your
EECS user name and password. Your account also comes with a certain amount of disk space. You can use this space
to store homework assignment les, and you dont need to bring your own disks or other storage media.
If malibu.eecs.uci.edu is down, then you can try another machine, such as vivian.eecs.uci.edu,
newport.eecs.uci.edu, or east.eecs.uci.edu. You can use the same user name and password regardless
of the machine, and your les will be the same.
Software and commands for remote login
You can connect to malibu.eecs.uci.edu from virtually any computer anywhere that has internet access. What
you need is a client program for remote login.
Previously, people used rlogin or telnet to connect to the server, and ftp or rcp to transfer les. However,
these protocols are insecure, because your keystrokes or output are in clear text and can be snooped by others. This
means your account name and password can be stolen this way. So, for security reasons, do not use either of these
Instead, use ssh as the primary way to connect to the server. ssh stands for secure shell, and it encrypts your network communication, so that your data cannot be understood by snoopers. For le transfers, use sftp or scp, which
are secure. You could also set up an ssh-tunnel so that previously unencrypted communications can be encrypted.
Depending on what computer you use, it may have a different implementation of ssh, but the basic function
underneath are all the same. Check out NACSs page on SSH:
or check the course web site:
If you are logging in from a Windows machine, you can use PuTTY.
MacOS X already has this built-in (use Terminal or X11 to run a unix shell). Most Linux distributions also
If you are logging in from an X terminal, you can use the command
% ssh malibu.eecs.uci.edu -X -l yourUserName
(note: % is the prompt, not part of your command) It will prompt you for your password. Note that the -X option
allows you to run programs that open X windows on your screen.
By now you should be logged in, and you should be looking at the prompt
Note: in the following writeup, we will show just
for the prompt, instead of
If you login to another machine, such as vivian, then the prompt would instead look like
You should change your password using the passwd command. The password will be changed on all the EECS
Sun machines, not just on malibu.eecs.uci.edu.
Try out the following commands at the shell prompt (See reference to the Unix Guide in section 1.3 for more
details about these commands.).
(change working directory)
(print working directory)
mkdir (make directory)
rmdir (remove directory)
(print the content of a le)
(print the content of a le, one screen at a time)
(print the arguments on the rest of the command line)
Most commands take one or more le names as parameters. When referring to les, you may need to qualify the
le name with directory references, absolute vs. relative paths:
.. (one level higher)
the root (top level) directory
Follow the Unix Guide
Follow the unix guide at:
Learn basic shell commands: list les, change directory, rename les, move les, copy les, show le content.
There is nothing to turn in for this part.
Learn to use a text editor
There are three editors that are available on nearly all unix systems that you may choose from.
pico is the easiest to get started with. A guide for pico can be found at:
vi is a very powerful editor, but is arguably a bit more difcult to learn. Follow the vi guide at:
Finally, is emacs another editor that you may use. emacs is also a powerful editor, but is a bit easier to learn than
vi. Follow the emacs guide at:
Learn how to edit a le, move the cursor, insert text, insert text from le, delete words, delete lines, cut/paste, save
changes, save to another le, quit without saving.
There is nothing to turn in for this part. However, it is critical that you get enough practice with your editor, so that
you can do the homeworks for this class.
Exercise 2.25 (text book, page 60) [20 points]
First create a subdirectory named hw1 (for homework one). Change into the created directory hw1. Then, use your
editor to create a C le named initials.c. Do not use a word processor and transfer or paste the content. The C
le should state your name and exercise number as a comment at the top of the le. Write the C program according to
exercise 2.25 in the text book.
Compiling your code
To test your program, it must be compiled with the gcc command. This command will report any errors in your code.
To call gcc, use the following template:
% gcc -o targetfile sourcefile
Then, simply execute the compiled le by typing the following:
Below is an example of how you would compile and execute the excersise 2.25:
% gcc -o initials initials.c
A brief text le, initials.txt, must be submitted as well that explains what the program does and why you chose
your method of implementation. For this homework a single sentence should be sufcient.
You also need to show that it works with your own test cases by turning in a typescript named initials.script.
For instructions on how to create a typescript, see Section 5 Typescript at the end of this document.
Submit your work
To submit your work, you have to be logged in to one of the following servers malibu, vivian, or east. The
submission will not work on the server newport.
Here is a checklist of the les you should have:
In the hw1 directory, you should have the following les in your unix account:
We do require these exact le names (i.e. do not replace initials with your actual initials). If you use different le
names, we will not see your les for grading. Now, you should change the current directory to the directory containing
the hw1 directory. Then type the command:
which will guide you through the submission process.
You will be asked if you want to submit the script le. Type yes or no. If you type n or y or just plain return,
they will be ignored and be taken as a no. You can use the same command to update your submitted les until the
Below is an example of how you would submit your homework:
% ls # This step is just to make sure that you are in the correct directory that contains hw1/
EECS 10 Fall 2008:
Assignment "hw1" submission for hschirne
Due date: Mon Oct. 6 11:59:59 2008
Submit initials.c [yes, no]? yes
File initials.c has been submitted
Submit initials.txt [yes, no]? yes
File initials.txt has been submitted
Submit initials.script [yes, no]? yes
File initials.script has been submitted
You just submitted file(s):
Verify your submission
This step is optional, but recommended. If you want to conrm which les you have submitted, call the following
This command lists your submitted les. Dont worry if you submitted too many les. We will only look at the
les with dened names (here: initials.c, initials.txt and initials.script) and ignore other les.
A typescript is a text le that captures an interactive session with the unix shell. Very often you are required to turn in
a typescript to show that your program runs correctly. To create a typescript, use the script command. Here is an
Type the command
into the shell. It should say
Script started, file is typescript
This means it is recording every key stroke and every output character into a le named typescript, until you
hit D or type exit.
Type some shell commands. But dont start a text editor!
Stop recording the typescript by typing exit.
Script done, file is typescript
Now you should have a text le named typescript. Make sure it looks correct.
% more typescript
Script started on Fri Sep 26 14:32:00 2008
You should immediately rename the typescript to another le name. Otherwise, if you run script again, it will
overwrite the typescript le.
Note: If you backspace while in script, it will show the H (control-H) character in your typescript. This is normal.
If you use more to view the typescript, then it should look normal.