CPE 101 Lab 1 - Getting Started

Ground Rules:

You must work on this lab individually.

Due: Preferrably by 4:30pm Tuesday, March 29, Worst case by 4:30pm Tuesday, April 5

Goals:


Orientation:

If you are actually enrolled in CPE 101 (not waitlisted or added) you should have a computer account that allows you to logon to most of the Computer Science Department computers. If you are adding the class, we will need to request an account for you using this form.

This lab helps you login, edit a file, and handin the file. The file you create will be handed in to me electronically in the same manner you will hand in all your labs and programs this quarter.


Part 1: Logging in

That being said, you can attempt to log in following these instructions to log on to server named vogon. You can do so in the Computer Science Lab (CSL) in 14-235 or from any other computer with an internet connection running UNIX, Linux, OS-X, or Windows. Being able to do this from home will increase your level of success in this class since it will enable you to work when and wherever you want. If you are using Windows at home you will have to download and install the SSH client described in the instructions linked above.

If you logged on to a machine in the lab you are still not quite on vogon. You'll have to start a terminal and connect to vogon using the command:

ssh vogon

Later, when you are done working on vogon, you will leave the machine by typing:

exit

Part 2: Create a new file using an editor

Once you are successfully logged on to vogon, you will need to create a file from the command line.  You should see a prompt that will look something like this:


        vogon: ~$

Now, enter the following command exactly as specified. I have made all of the commands that you are to enter in bold face.


        vogon: ~$ mkdir cpe101  (create a directory named 'cpe101')
        vogon: ~$ cd cpe101     (change to the cpe101 directory)
        vogon: ~$ vim my_sample (edit my_sample using vim)

Part 3: Editing the file using VIM

  Once the VIM screen appears, you can now start editing the file.  Remember, vim is modal editor - there are 2 modes:  command mode and insert mode.  You can refer to the reference card for all of the keys, but here are some common commands:

i (command mode)
switch to insert mode
Esc (insert mode)
switch to command mode
j
move down
k
move up
h
move left
l
move right
x
delete character
:w
save file
:q
exit vim


     Your file should contain the following 2 sentences

        This is my lab 1 file.
This class is CPE 101.

     Save the file and quit out of vim.

Part 3: Edit, compile, and run a first program

Copy the miles2feet.c and checkit.h files into your directory.


       
vogon: ~$ cp ~djanzen/www/courses/101S11/labs/lab1/miles2feet.c .
       
vogon: ~$ cp ~djanzen/www/courses/101S11/labs/lab1/checkit.h .

Note that the ~djanzen means in djanzen's home directory, and the . means in the current directory.

Type ls to confirm that two files are now in your directory.

Use vim to edit miles2feet.c. Add a variable miles, use printf and scanf to read a value into miles, then use the function to convert miles to feet and print the result.

  Compile your program with the following command:
       
vogon: ~$ gcc -Wall -Werror -ansi -pedantic miles2feet.c -o m2f

  Run your program with the following command:
       
vogon: ~$ m2f

  If everything works, show your instructor and turn in your program using the following command:

       
vogon: ~$ handin djanzen 101_lab1 miles2feet.c  
       
Submitting miles2feet.c... ok
                djanzen@vogon: ~$ exit

   
  Complete this survey.

   Congratulations, you are done with lab 1!  If you would like more practice with vim, I suggest running through the vim tutorial link on Blackboard.  I have also posted a table of some useful UNIX commands:


Command
Usage Example
Description
cd
cd my_dir
Change to my_directory
more
more testfile
Look at the contents of testfile
pwd
pwd
Show the present working directory
ls
ls
List the files in the current directory
mkdir
mkdir test
Make a new directory called 'test'
rm
rm testfile
Delete the file named 'testfile'
hostname
hostname
Show the name of the computer
exit/logout
exit
End the current shell session