Summary
of Creating Programs on UNIX
CS
161: Introduction to Computer Science 1
Program Assignment:
- Login
to Odin using ssh or putty (odin.pdx.edu). If you don't have an odin account
or password you will need to get one. If you don't have one go to: www.account.pdx.edu and for help go to: www.oit.pdx.edu
- Start
up the program called ssh – you should be able to find a free site from
which to download it. It is a secure shell program and allows your computer
to act as a ‘dumb terminal’ for logging in remotely. You start up ssh by
double clicking on it.
- Then, connect to: odin.pdx.edu
- Use your odin login name and
password
- When you login into Odin, Hit
return. Then hit 4
<enter> to exit the menu.
- The very first time you login to Odin to do
your Computer Science homework, you should create a directory where your
programs will live (and where you will work from. To make a new directory
type:
mkdir cs161
<enter>
- From then on, you will need to
travel to that directory to actually get your work done. This will need to
happen each time you login. So, to enter that directory to start to work type:
cd cs161 <enter>
- Now you are ready to start typing in your
program. Use pico to type in a program. So, type at the unix prompt:
pico
prog1.cpp <enter>
- Enter in the program; you can use the error keys and
delete to fix mistakes and move the cursor around. There is a menu that
appears at the bottom of the pico screen.
- When done hit control o at the
same time to write it out and control x to exit.
- Compile your C++ source code file. The
command to do this is:
g++ prog1.cpp<enter>
- If your
program successfully compiles, it will produce a file named 'a.out'
in your directory. Otherwise, you will need to correct syntax errors
before continuing - by using pico again:
pico prog1.cpp<enter>
- One common mistake is to make typos!
- Run your program by typing:
./a.out
- On the due date, Email your program to karlafgr@cs.pdx.edu
(notice
the email address is different than your teacher’s email address…)
One way to email in UNIX is to use pine.
This allows you to attach the program file to your email message, which the
grader likes the best.
Before you use pine, you should find out
the name of the path where your file is located. Type pwd<enter> and see what it says…my directory says:
/u/karlaf/cs161
Now we are ready to get into the pine
email system:
pine <enter>
·
Select C to compose a message
·
Put
karlafgr@cs.pdx.edu in the To: area
·
Arrow
down to the Attchmnt: area
·
Type
in your program name with its full path
(e.g., mine is: /u/karlaf/cs161/prog1.cpp)
·
The
subject should have (a) class name, (b) the word Submission, and (c) your name
(e.g.,
CS161 Submission from Beth Miller)
·
The
body of the email can be left blank unless you need to communicate something to
the grader.
·
·
To
send the email press control X at
the same time
- Another way to email programs is to
copy them onto your PC and email them as an attachment using your normal
email program (I use outlook).
A
great program for transferring files from UNIX to your PC (and vice versa) is
WinSCP. It is free
software that you can download and it works great.