CSC 101: Working at Home



1. Introduction

This handout has information about tools for working on CSC 101 programs at home. You'll need different stuff depending on which computer platform you use -- Linux, Mac OS, or Windows.

2. Copying Files to and from Unix1

When you connect to unix1 from home, you will most likely need to extend its network address from just "unix1" to "unix1.csc.calpoly.edu". Use this longer address for all commands that require a computer network address, either on the command line or in a dialog window.

In some cases, you'll need your unix1 user name as part of the address. The format of this kind of address is "username@unix1.csc.calpoly.edu". This user name is necessary when the user ID on your home computer is different than it is on unix1. If your home computer ID happens to be the same as on unix1, then you can leave off the "username@" part of the address.

Platform-specific details of file copying follow.

2.1. Linux

If you're running Linux at home, the easiest way to copy files is with the scp command in a terminal window. For example, suppose you have your solution to programming assignment 1 stored on your home machine in a directory named ~/csc101. To copy your program up to unix1, do this in a terminal:

cd ~/csc101
scp make_change.c "username@unix1.csc.calpoly.edu/csc101"
This assumes you also have a directory named ~/csc101 on unix1. If you want to copy the file some place else on unix1, just put that name in the second argument to scp.

The scp command prompts for your unix1 password. After you enter it, scp prints out a progress message as it copies the file.

You can copy files from unix to home. To do this, just reverse the order of the scp arguments. For example, to copy the lab 1 example file to your current working directory at home, do this:

"scp username@unix1.csc.calpoly.edu:/home/gfisher/classes/101/labs/1/example1.c ."
Note that the tilda character won't work in remote file paths, so you have to use /home/gfisher instead of ~gfisher.

The different forms of arguments to scp work just like they do for the regular UNIX cp command. See the 101 UNIX basics handout for further information.

The scp command should be pre-installed in Linux. If it's not on your machine, you can get it at

http://www.openssh.com

If you want to get fancy, you can set up an authorized key file, so you don't need to enter your password every time you copy files. Check out the following site for instructions on how to do this:


http://www.debuntu.org/ssh-key-based-authentication

2.2. Mac OS

Both a terminal app and scp are pre-installed in Mac OS. The terminal is in /Applications/Utilities/Terminal.app. Run scp from the terminal exactly as described above for Linux.

If you'd like to use a GUI program for remote file transfer, check out Fugu. It's at http://rsug.itd.umich.edu/software/fugu/

2.3. Windows

The most common way to copy files to and from Windows is with an SSH client. You can get a free, licensed download from here: http://users.csc.calpoly.edu/~gfisher/classes/101/handouts/SSHSecureShellClient329.zip . Unzip the file, install it, and read the 'Help' menu for instructions.

If you install cygwin, as described below , you'll have a command-line version of scp on Windows. It works the same as on Linux and Mac OS.

3. Logging in to Unix1 from Your Home Computer

3.1. Linux

For logging in to unix1, use the ssh program. It works just like it does in the CSL, except you probably need to use the extended form of computer address, like this:

ssh username@unix1.csc.calpoly.edu
You'll be prompted for your unix1 password, just like you are in lab.

If you set up authorized keys for scp, they'll work for ssh as well. This means you won't have to enter your password when you login.

3.2. Mac OS

Both a terminal app and ssh are pre-installed in Mac OS. The terminal is in /Applications/Utilities/Terminal.app. Run ssh from a terminal exactly as described above for Linux.

3.3. Windows

The Windows SSH client comes with both a file transfer program, and a secure shell program. There should be icons for both on you Desktop.

The secure shell program provides a terminal window you use to login in to a remote computer, such as unix1. Read the 'Help' menu for instructions.

4. Compiling and Running Your Programs from a Terminal

4.1. Linux

The gcc compiler is built into Linux. Make sure you have version 4 of the compiler by running this command from a terminal:

gcc --version
It should say something like
gcc (GCC) 4.3.0 ...
If it reports some version less than 4.0, go here to get the 4.3.0 release: http://gcc.gnu.org/releases.html . It's not critical that you have exactly 4.3.0, but that's the version on unix1. Any 4.x version will be OK, since you always need to compile and run on unix1 before you hand in.

You compile with gcc on the Linux command line exactly as you do in the CSL. You also run the compiled programs in the same way as in the CSL.

4.2. Mac OS

If you don't have the developer tools installed, go to http://developer.apple.com . Click on the 'Mac Dev Center' link, and register for a free account. Do this by clicking on the 'Register' link in the first paragraph at the top of the page.

Once you're registered, sign in and follow the 'View all downloads' link near the bottom center of the page. In the search oval near the top left of the page, enter "xcode". If you're running Mac OS Lion (10.7), download and install 'Xcode 4.3. for Lion' at the top of the list. If you're running Mac OS Snow Leopard (10.6), download and install 'Xcode 3.2.6 and iOS SDK 4.3 for Snow Leopard', near the bottom of the list.

Once Xcode is installed, you'll have a command-line version of gcc that runs precisely the same as it does for Linux.

4.3. Windows

To get gcc for Windows, I recommend cygwin.com . It provides gcc, plus a Linux style command-line environment for Windows. Goto the cygwin site and follow the 'Install Cygwin' link on the top-left of the page. Get the setup.exe file, install it, and follow the installation instructions.

Except for one place, you can click on the 'Next' and 'Yes' buttons to accept the default values in the installation wizard. The place you need to choose values other than the defaults is when you get to the 'Select Packages' window. In that window, click the '+' next to 'Devel', then scroll down to the item 'gcc4: GCC Release series 4 compiler'. Click the little arrow goodie next to 'Skip' until it says '4.3.4-4'.

Also in the 'Select Packages' window, click the '+' next to 'Net', then scroll down to the item 'openssh: ...'. Click the arrow goodie next to 'Skip' until it says '5.9p1-1.'

Now finish out the installation wizard. When cygwin has been installed, you'll have a Cygwin Terminal short cut on your desktop. This behaves just like a Linux or Mac OS terminal, with gcc, scp, and ssh. You can talk to your instructor for further details on using cygwin.

An alternative Windows C compiler is from MinGW. Instructions for downloading and installing it are available from CSC 101 instructor Aaron Keen, at http://users.csc.calpoly.edu/~akeen/courses/csc101/references/gcc.html

5. Editing Your Programs with Emacs

5.1. Linux

Emacs should be pre-installed in Linux. It behaves just like the version installed on the CSL machines. If Emacs is not installed in your version of Linux, you can get it at http://ftp.gnu.org/gnu/emacs . The latest version as of April 2012 is at the link http://ftp.gnu.org/gnu/emacs/emacs-23.4.tar.gz near the bottom of the page.

5.2. Mac OS

A native Mac OS version of Emacs is available at http://emacsformacosx.com . It has a Mac OS look and feel, but otherwise behaves like Linux emacs.

5.3. Windows

A native Windows version of Emacs is available at http://ftp.gnu.org/gnu/emacs/windows . The latest version as of April 2012 is at the link emacs-23.4-bin-i386.zip near the very bottom of the page. It has a Windoze look and feel, but otherwise behaves like Linux emacs.

6. Editing Your Programs with jGrasp

You can get jGrasp at http://jgrasp.org . The downloads page has instructions for installing on Linux, Mac OS, or Windows.

There's an installation tutorial here http://www.jgrasp.org/tutorials187/01_Installing.pdf which you can also get to by clicking on the 'Installation' link in the middle left of the main jGrasp page.

The previously cited gcc installation page from Professor Keen also has a brief set of instructions for installing jGrasp. See (again) http://users.csc.calpoly.edu/~akeen/courses/csc101/references/gcc.html .

The jGrasp main page has links to useful information, listed along the left of the page, under the headings 'Documentation', 'Intro Videos', and 'Tutorials'. Your 101 instructor can help you in lab and/or office hours if you have jGrasp questions.