Beruflich Dokumente
Kultur Dokumente
CS 1313
1. Objectives
Log in to ssh.ou.edu. Use Unix commands: cd, chmod, cp, exit, gcc, ls, mkdir, nano, source. Type in, compile, and run a C program. Submit source code to D2L.
2. Grading
We'll explain more in lecture and in lab about what this means, but here's the grading summary for this project: Milestones 20% Ask the user for their age. 25% Input the age from the user. 25% Tell the user their age back again. 15% Return EXIT_SUCCESS to the operating system. 10% Documentation. 5% Formatting. Penalties -100% More than one day late (except for byes, as explained in the syllabus). -50% Compiling fails. -20% One day late. -20% Resubmission for uploading the wrong file or failing to upload correctly. Each project has different milestones contributing to the grade. You can get partial credit for partially completed milestones. Across projects, we will keep consistent the contributions due to documentation, formatting, compiling, late submissions, and correcting wrong submissions. For project 1, we actually give you the entire program, so if you follow instructions correctly, you should get full credit. If those penalties seem harsh, just learn to get it right. Make sure you test your programs, and make sure you upload the right file on time. On the plus side, you can't get a negative grade on a project. Doesn't that give you warm fuzzies?
3. Log in to ssh.ou.edu
In this course, you won't be running your C programs on your own computer. Well, you can do that if you want, but you also need to run them on a common Unix (well, Linux) platform that we'll all be sharing. We'll pretend to connect to a computer called ssh.ou.edu, but that's really a faade that redirects you to either kennedy.itsc.ou.edu or polk.itsc.ou.edu or maybe others. To run programs on these computers, you need a tool supporting SSH (secure shell) to connect to ssh.ou.edu. On Mac or Linux, you first bring up a terminal to use ssh. On Windows, you need a separate tool, such as PuTTY (http://www.chiark.greenend.org.uk/~sgtatham/putty/). It is already installed on the lab computers, but you if you want it on your own computer, you will likely need to install it yourself. Page 1 of 10
For both PuTTY and FileZilla, you'll log in to ssh.ou.edu with your 4x4 and corresponding password, the same as for oZONE or D2L.
Later, when you launch PuTTY again, you can click on the ssh.ou.edu session, and click Load. That way, you don't need to type it in or reconfigure it again. Once you have the session information loaded (as seen under Host Name), click Open to connect to the remote computer. The first time you SSH to a remote machine, it asks you if you trust that computer. There's no convenient way to prove that the remote host is really what it claims it is. But once you have its fingerprint stored on your machine, you'll be warned if it ever changes. If it does, that might be a sign that someone is intercepting the network communication. So, when PuTTY asks you about saving the information, say yes. (Sadly, for campus Windows machines, saved application settings are lost whenever you log out. But saving settings could be useful on your own computer.)
Page 2 of 10
Once you decide to trust the connection, you can log in with your 4x4 and password.
SSH on Mac
As mentioned earlier, to use SSH on a Mac, you first need to bring up a terminal. You do this with the Terminal application. It is usually found in Finder under Applications > Utilities. Once you have a terminal Window, enter the following command and then follow instructions: $ ssh <your4x4>@ssh.ou.edu The first time you connect, you will likely be asked about whether you trust the remote machine, just as for PuTTY on Windows. To connect, you have to answer yes. See the discussion above for more info.
Windows or a Macintosh, except Linux is free. When you use a Linux computer, it normally looks and acts a lot like using Windows. However, in CS 1313, we won't be using Linux normally. We'll be using a command line interface, which we'll also call the shell. Using text commands at a command line has pros and cons vs. using a graphical interface. When typing commands from here, make sure to include spaces between other symbols or letters exactly when shown.
Page 4 of 10
You can stay logged in to complete project 1, but whenever you want to log out, just enter: palm5988@kennedy:~$ exit When using PuTTY, the window closes when you are logged out. When using a Mac terminal, you still need to exit that as well if you have nothing else to do there. The key combination Ctrl+D also works to exit a session. Now for the project.
Page 5 of 10
/* Tell it back. */ printf("%d years! Wow, that's old!\n", age); /* No errors happened that we noticed. */ return EXIT_SUCCESS; } You can save your file by Ctrl+O then Enter (if you don't want to change the name). Quit nano by Ctrl+X and following instructions. To compile programs, we will be using the GNU C compiler. However, using it is a bit tricky. You have to tell it the name of the program you want to create (output), and it's easy to make mistakes doing that. So let's make a "shell script" to run gcc for us. Use nano to create a new file called "build": palm5988@polk:~/cs1313/project1$ nano build Enter the following contents, then save and exit (quit) nano. gcc -o person person.c Then you can "change the mode" of your build script to let you (the owning user) run (or execute) it as a command. The chmod command can also be used for changing file access permissions. palm5988@polk:~/cs1313/project1$ chmod u+x build Now run your build script and list your directory contents afterward. You have to put "./" first to run commands in the current directory: palm5988@polk:~/cs1313/project1$ ./build palm5988@polk:~/cs1313/project1$ ls -l total 28 -rwx------ 1 palm5988 faculty 22 Jan 17 17:01 build -rwx------ 1 palm5988 faculty 4905 Jan 18 15:06 person -rw------- 1 palm5988 faculty 561 Jan 18 15:05 person.c Now, run your person program (if you had no errors building it), entering whatever age you want: palm5988@polk:~/cs1313/project1$ ./person How old are you? 42 42 years! Wow, that's old! That's what success looks like for this project. You've written and run programs in two different languages (C and shell)! You can exit from the remote computer when you are done.
Or as another hint, it's not the one labeled 010. That's the main lecture section. You'll find quizzes there, and your grades will be there, too, but there'll be no place to submit projects at section 010! Once you get to your lab section site, click the link Dropbox, then choose the correct dropbox for the project. That means Project 1 this time.
When the project folder comes up, click Add a File then choose a file from your computer.
The program you need to upload for each project is your .c file! Here, that's specifically person.c. Don't upload the .c~ file nor the person executable. For some projects, you might have other files you also need to upload. If you upload the wrong file, and need to correct it after the due date, talk to your grader. The standard penalty (as mentioned earlier) is -20% to resubmit the correct file later!
Page 7 of 10
The files and folders (i.e., directories) at ssh.ou.edu are the same ones that Windows computers on campus see under the mapped H: drive. You can access them directly as if they were on the Windows computer itself.
If you have the file available from your computer, you can choose it and then upload it in your browser to D2L.
After this, you still aren't done yet! If you stop here and wait until you are late, talk to your grader and expect -20% for failing to upload correctly. D2L requires you still to click the Submit button after uploading.
Page 8 of 10
Follow all the steps, and make sure you get an email confirming your submission! If you don't get an email, either you have your email address misconfigured (and you'll miss other important info) or you didn't submit your project!
Page 9 of 10
You'll need to enter your password, and you'll also need to establish that you trust the remote computer, just as you did for PuTTY or ssh. Click the checkbox to always trust this host, as discussed earlier for PuTTY.
Once you are logged in, you can navigate to your project1 folder and copy the person.c file to your own hard drive. On one side are your local files, and on the other side are the remote files. You can drag and drop files from one side to the other. You can safely ignore most other details in this window.
Once the file is on your own hard drive, you can submit it to D2L using your web browser.
Page 10 of 10