CIS71 Lab01 - Remote Use of the CIS Dept LUCAS Server         DUE: (Noon, Wed, Sep 6, 2006)                                                                        


Objective: To become familiar with the CIS Laboratory facilities, Linux commands and tools to:
  1. Remotely access your individual course account on the CIS Department Lucas Server
  2. Create a Lab01 directory (folder) in the default path in your account
  3. Use the Linux tools to create, edit, compile and test a C program.
  4. Use Pine email to submit your program source and capture files to your Course Email Account.

1. The CIS Lucas Server is directly accessible from some of the computers in the CIS Laboratories. It is indirectly (remotely) accessible from on-campus computers via a University account and off-campus via the internet. For details, see Remote Access and Login to CIS Dept Lucas Server (below).

2. Use the Common Linux Commands (below) to navigate your account and create a Lab01 folder in your default path.
   a. Display the default path e.g. pwd
   b. Create directory Lab01 e.g. mkdir Lab01
   c. List directory contents to show that Lab01 was created in the default path e.g. ls or ls –l
   d. Change the default path (current directory) to Lab01 e.g. cd Lab01
   e. Display the default path to show that Lab01 is now part of the path

 

3.1 Create a program file named mileskm.c (see Using the Pico Editor –below)
   a. Activate the pico editor to create a program mileskm.c e.g. pico mileskm.c
   b. Type in the program Miles to Kilometers written below. Note that the pico editor does not use the mouse. WARNING: In the scanf itself, in the quotes "%lf" the character after the % symbol is the letter el not the digit one.

 

/*

 * Converts distance in miles to kilometers.

 */

#include <stdio.h>              /* printf, scanf definitions */

#define KMS_PER_MILE 1.609      /* conversion constant       */

 

int

main(void)

{

      double miles,  /* input - distance in miles.       */

             kms;    /* output - distance in kilometers  */

 

      /* Get the distance in miles. */

      printf("Enter the distance in miles> ");

      scanf("%lf", &miles);

 

      /* Convert the distance to kilometers. */

      kms = KMS_PER_MILE * miles;

 

      /* Display the distance in kilometers. */

      printf("That equals %f kilometers.\n", kms);

 

      return (0);

}

 

       Navigate with the arrow keys, backspace, delete and enter. 
       The editor commands are shown at the bottom of the screen e.g. ^X (control-X) is how you exit the program.
            - Type ^X and respond Y to the prompt Save Modified Buffer?
            - Hit Enter key in response to the prompt Filename to write mileskm.c
            - You should now be back at the Linux prompt

3.2 You are now ready to compile the program e.g. translate from a C code source file named mileskm.c to a machine executable file named mileskm (or a.out). Note that the source file has a .c suffix and the executable file does not have a suffix.
   a. The compiler command gcc mileskm.c –o mileskm is of the form:
              gcc [source filename] –o [executable filename]
   b. If the command prompt returns (e.g. no compiler messages) then your compile is successful and you are ready to test. (3.3 below). Compiler messages indicate an inconsistency in the code. The cryptic message is usually preceded by a line number in the source file.
   c. You can reactivate the pico editor with the cursor at the line number in question by typing:
              pico +24 mileskm.c (e.g. at line 24 –note that the + is required)
   d. Note if you had no messages, we suggest you go back into pico anyway and create a typing error just to see what happens.

 

3.3 To test the program type the executable file name mileskm at the command prompt. Repeat the test using different values of miles (e.g. zero, large and small values, positive and negative values) until you are satisfied that the program works.  If you compile your program using the command form

        gcc mileskm.c

without specifying the executable file name mileskm, you need to type the command a.out in order to execute your program.  a.out is the default name of the an executable when you fail to provide an executable file name in your gcc command. 

 

3.4 The cycle of edit, compile, test,… continues until you are satisfied that you have a correctly functioning program. Note that Linux saves all your commands and the up-arrow key displays the last command typed. You can avoid retyping the edit, compile, test commands by repeatedly using the up-arrow key until your previous command appears (then just hit enter).

 

Additional Notes:

4. Use the Pine email program to submit Lab01 for grading to your TA’s email account e.g. mail0713 for cis71.003. You will attach the source files mileskm.c. You will NOT attach the executable file mileskm.
a. At the Linux command prompt, type pine. You may see a welcome message the first time you use the program. Read and close the welcome message.
b. Type C or move the up-arrow to the Compose Message line and hit enter.
c. You will see an email message template. Like pico, pine displays the different command choices at the bottom of the screen.
d. Fill in the To: line with the TA’s email account.
e. We suggest you fill in the cc: line with your personal email address so that you may determine that the message was sent with the files correctly attached.
f. Fill in the Subject: line with Lab01 (nothing else) You may optionally type a message in the message-text area.
g. To fill in the Attachment: line, we will use Pine commands. Type ^J (control J). The prompt File to Attach appears. Typing ^T (control T) allows you to browse and select the file to attach without having to type the full pathname. Use the arrow keys to navigate to the Lab01 directory. Press enter to display the directory contents. Navigate the cursor over mileskm.c and press enter. You will be prompted for Attachment comment; Press enter. The main message should reappear with the full path for mileskm.c at the Attchment line.
i. To send the email message: type ^X (control X). Response will be a message sent confirmation.
j. You should be back at the Pine Main Menu. Type Q to exit Pine. Respond Y to the prompt Really quit pine? to get back to the main menu.

For more details on using Pine see http://www.temple.edu/cs/unix/a14pine.html
Note that the reply from the Lab Instructor will be sent to your course account.


5.  Type exit to log off your account. Sometimes you may have to type exit twice to log off.

REMOTE ACCESS AND LOGIN TO CIS DEPT LUCAS SERVER

1. The CIS Lucas server is accessible from on-campus computers via a University account. A University account may be obtained using your Student ID at the Help Desk in the basement of Wachman Hall (enter rear of building, turn right thru double doors and enter right-hand office).
2. The server is also accessible from the internet.
3. The Lucas Server URL is http://lucas.cis.temple.edu/
4. Use Internet Explorer or Netscape to access this URL. The screen will have a black background with green, red, or blue text (scroll down and read the Notices and a lot of good information).
5. Click on SSH Login to this system (in blue or red just above Notices).
6. Scroll down past the warning to the bottom of the screen and press enter (be patient, access may be slow).
7. Supply login and password for your Lucas Course Account (not your University Account).
8. You may be prompted to enter password again.
9. A linux shell window will open. This window is a command line interface which does not use a mouse. You cannot transfer files using this interface (see SSH Resources on the lucas server home page e.g. WinSCP) .
10. Type exit to close the window when you are finished.

COMMON LINUX COMMANDS

Terminal Window is where the commands below are executed. In remote access to lucas, the environment can only be a terminal window. Under linux in the laboratory, open a terminal window from red hat -> system tools -> terminal

COMMANDS A more complete list and explanation of commonly used Unix commands can be found at: http://www.temple.edu/cs/unix/commands.html

pwd    (print working directory) Displays the default path

ls     (list directory contents)    Displays the files and folder names in the default path
ls –l     (letter l) Displays files and folders in default path with considerable detail

more <filename> Displays contents of <filename> one screenload at a time. Hit spacebar to see next screenload (can only go forward); Type Q to quit more.

cd <foldername>    Change the current directory. Add <foldername> to the default path by going down one level to <foldername> (Use pwd to see new path)
cd ..        Go up one level in the default path

mkdir <foldername>     Create a directory <foldername> in the default path. (Use ls to verify)
rmdir <foldername> Remove an empty directory <foldername> (See rm for deleting files)

rm <filename> Remove (Delete) <filename> in the default path (Use ls to verify)

mv <fromfilename> <tofilename>    Rename <fromfilename> to <tofilename>
mv <filename> <tofoldername>     Moves <filename> to folder <tofoldername> which must be in the default path. (This is a file cut and paste in windows)
cp <fromfilename> <tofilename>     Make a Copy of <fromfilename> and call it <tofilename> in the default path

Control-C (hold control key down and type C) to cancel current activity and return to the prompt

up arrow    Displays previous command. Hit enter to activate that command. Saves typing. Each time up arrow is pressed, goes back one command. To reset back to last command: Hit enter on empty line.

exit    Terminate the current shell. If the terminal window is the current shell, closes the window.

Note: A Unix shell is the vehicle for interpreting and executing Unix commands. A terminal window opens with a shell. Sometimes, a shell is superimposed on top of the terminal window shell e.g. the capture command. In that case, TWO exit commands have to be issued to terminate the window.


Lab01.doc F2006