Best Viewed with:

800x600 or better
 

Lab 1 - Introduction to Unix

0. Acquire an ECT unix account (you may also choose at this time to install GNU C++ (g++) compiler and GNU Emacs on your local machine, in addition to ECT account).

1. Login to ECT server tiglon.ecst.csuchico.edu

2. Change your password: passwd

Passwords should be 7 to 8 characters long, and contain a mixture of upper and lower case letters and numbers.

3. Find out where you are: pwd

4. List the files in your home directory : ls

5. List all files, including hidden ones:     ls -a

6. List file details:     ls -l

7. Consult the online manual:      man ls

8. Create a new directory: mkdir Csci15b

9. Move to that directory:    cd Csci15b

10. Move back to your home directory: cd (always takes you home)

or .. (takes you to parent )

11. Create a file, using GNU's emacs editor (full development environment), or pico (limited subset of emacs): emacs heatwave.cxx
-or- pico heatwave.cxx

Enter the following :


// heatwave.cxx
//written by Michael Main

#include <iostream> //Provides cin, cout
#include <cstdlib> //Provides EXIT_SUCCESS

//make identifiers in Standard Library available
using namespace std;

//Defined to make the program readable
const double PI = 3.14159;

int main()
{
double height; //Height of a tree in feet
double radius; //Radius of a tree in feet
//Cubic feet of wood to heat house for a day
double requirement;
double volume; //Volume of the tree in cubic feet
double days; //Number of days that tree will heat house

//Prompt user for input and read responses
cout << "How tall is your tree in feet?" << endl;
cin >> height;
cout << "What is the radius of the tree in feet?" << endl;
cin >> radius;
cout << "How many cubic feet of wood will heat a house for a day?" << endl;
cin >> requirement;

//Computations
volume = height * PI * radius * radius;
days = volume / requirement;

//Output days
cout << "That tree will heat a house for " << days << " days." << endl;

return EXIT_SUCCESS;


12a. SAVE OFTEN (w/out exiting, use ctrl-x-s for emacs). Now, add header documentation that includes information about who & when you modified/accessed the code; date last modified; platforms created/tested on; general description of the problem; I/O requirements; etc.

12b. When done, exit the editor and save the file (ctrl-x-c for emacs)

13 Move this file to your Csci15b directory

mv heatwave.cxx Csci15b

13. Compile your file:

g++ -Wall heatwave.cxx

14. If there are errors, go back to the editor, fix them, and compile again.....

15. See what file was created ls -l

16. Now compile with the -o switch:

g++ -Wall heatwave.cxx -o heatwave

17. Check again and see what file was created ls -l

18. Check the permissions on your new files.

19. Change the permissions on heatwave.cxx so that no one else can read it.

chmod 600 heatwave.cxx

20. Run the program heatwave

21. If time permits, create more files. Copy (cp) them from one directory to another, and from one filename to another filename, and then delete them (rm),

22. SUBMIT heatwave.cxx file to your professor/TA
(distance students submit .cxx source file as a text attachment, via email to renner@ecst.csuchico.edu, with "SUBMIT LAB1" in subject header;
local students use turnin directory procedure).

Maintained By:  renner@ecst.csuchico.edu
Last Modified:  Oct.25, 2002