scp
/ssh
commands for getting/sending homework files?autograde
program?.bak
file and do I need to submit them as well?
This guide is based on the most frequent problems that students encountered last semester when attempting to submit their work. It is intended to supplement the guides to Linux and the Zoo Submit System (ZSS) that are hosted on the course website. It is aimed at beginners and tailored to specific quirks of the Zoo environment. See also:
If you are following the steps in a particular solution and it’s not working or you don’t understand it, please email the instructional team or come to help hours as soon as possible! The skills that make you fast and efficient on your own computer do not necessarily translate into the Unix, command-line world. So don’t worry if you find yourself frustrated in the early going – it doesn’t reflect on your ability to learn computer science!
To set them apart typographically, and to allow code-snippet formatting in Markdown, I will “quote” the following items inside back-ticks.
Enter
, j
, ~
, and Ctrl
/c/cs201/bin/submit
cd
,ls
, and grep
grep -i hours hw0.rkt
To follow along with a command, type it into your terminal exactly (making sure your file paths are correct with respect to your CWD, or “current working directory”) and without any leading whitespace. To run the command, press Enter
.
The angle brackets <
and >
are used as placeholders for an example <file_name>
or for unique identifiers. Your <NetID>
is necessarily different from mine, but the paths to our respective user-spaces on the Zoo have the same structure: /home/accts/<NetID>
.
I will often refer to the generalized homework file hw<as_no>.rkt
. When you go to run a particular command on a homework file, just fill in the number of the relevant assignment.
scp
/ssh
commands for getting/sending homework files?The scp
syntax is:
scp <file_you_want_to_send_or_receive> <destination>
Zoo –> Me. One-liner for getting a homework assignment (assuming it has been posted) onto your own computer. This also assumes you are currently in the local directory to which you want to transfer the file (i.e. you’re fine with the Zoo file ending up in your CWD, denoted by ./
).
scp <NetID>@node.zoo.cs.yale.edu:/c/cs201/hws/hw<as_no>.rkt ./
Note that the homeworks will always be available via a browser at:
https://zoo.cs.yale.edu/classes/cs201/Fall_2018/assignments.html
Me –> Zoo. Send a file that exists in your CWD from your computer to your userspace on the Zoo. Make sure the target directory ends in a forward slash (/
) so that bash interprets cs201
as a directory and not a file. Otherwise, you’ll end up sending your file but it will now be named cs201
, which is confusing! If the ~/cs201
directory doesn’t exist, you will see an error message that /cs201/
is not a directory. Use mkdir
to create the cs201
subfolder or just transfer the file to ~/
.
scp <file_name> <NetID>@node.zoo.cs.yale.edu:~/cs201/
Remotely log in to the Zoo cluster with:
ssh <NetID>@node.zoo.cs.yale.edu
Bash hides your typing of passwords for security reasons. You can still type as normal and use Backspace
if you suspect you’ve made a typo.
When you scp
or ssh
into the Zoo, if it’s your first time doing so from a particular computer, you will see the message:
The authenticity of host 'node.zoo.cs.yale.edu (128.36.232.19)' can't be
established.
ED25519 key fingerprint is 0f:28:c3:7d:10:de:2f:fa:3b:ec:93:7b:09:b5:04:d7.
Are you sure you want to continue connecting (yes/no)?
Short answer: type “yes” or “y” and press Enter
. This is just a boilerplate warning you don’t need to worry about.
Long answer: bash will “remember” the Zoo cluster by adding its hostname and IP address to the file ~/.ssh/known_hosts
. The fingerprint has to do with the cryptographic protocol that makes “secure shell” communication possible. See:
To get a sense for the purpose behind the hostname “node.zoo.cs.yale.edu,” run:
whois 128.36.232.19
Either you have Windows 10, or you have Windows <10.
You can activate and download the Linux Subsystem for Windows. This will give you a full-on Unix shell, equivalent to the terminal on the Zoo machines or a Mac. Good directions from Microsoft are here:
https://msdn.microsoft.com/en-us/commandline/wsl/install_guide
Once you have the “Bash on Ubuntu on Windows” shell running (and saved to your Taskbar!), you will be in your Linux-area home directory, also abbreviated ~
. cd
over to where your stuff is actually located with:
cd /mnt/c/<Username>/Documents
Replace c
with d
or whatever the name of your primary drive is. The Linux subsystem creates a full Linux file tree (with a root and /usr/bin
just like on the Zoo). But unfortunately, this “Linux area” is not accessible via the Windows file explorer. So you’ll want to keep your files where you normally store them in My Documents
, for instance. Then when you launch the Ubuntu shell (NOT PowerShell or cmd.exe!), move to that location by cd
-ing to the “mounted” or mnt
directory which is the way that the Linux area makes sense of and can access the Windows drives.
You can now follow along with any of the scp
or ssh
commands no problem!
You’ll need to use PuTTY, which allows you to launch a shell that is logged in remotely to the Zoo. You will additionally need PuTTY’s pscp
utility for file transfers. Once pscp
is installed, you can use it as a command from Windows PowerShell or even cmd.exe. It has the same syntax and purpose as scp
, although be careful, since Windows uses different conventions for filenames (most infamously, back-slashes instead of forward-slashes). The manual and download page for PuTTY is here:
http://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
More information on PuTTY will be posted soon.
The first thing you need to do is register for a Zoo account at:
Leave “bash” as the preferred shell and select the checkbox for cs201. Click on the “Submit Changes” button. This will create or update your Zoo account and place a folder named cs201
in your Zoo home directory. Make sure you see the following message (in a green-colored font) at the top of the Zookeeper page:
Added course cs201, ‘Introduction to Computer Science’
If you enrolled in a computer science course, you should have card access to Arthur K. Watson Hall (AKW) in the evenings or on weekends when the doors are locked. Whether remotely or in person, you always use your NetID and password to log in to a Zoo node.
Zookeeper does two things when you register for cs201. It first creates a folder with your name inside the directory /c/cs201/class
. When you ls
the contents of this class
directory, you should see something of the form:
<last-name>.<first-name>.<netid>
or, in my case:
krewson.stephenwilliam.swk2
Zookeeper also creates a symbolic link to this folder in your home directory. This is the cs201
folder mentioned above. You should see something like the following when you run ls -la ~
:
cs201 -> /home/classes/cs201/class/krewson.stephenwilliam.swk2
If your named folder does not exist, /c/cs201/bin/submit
will think you do not have the correct permissions for submitting work. Hence you will be told:
submit.pl: unkown student UNKNOWN
The extension .pl
tells us that the submit
program has been written in the Perl programming language (and then compiled to an executable).
Here is how to resolve the “UNKNOWN” problem:
~/cs201
and store it elsewherecd
to your home directory and delete the link with rm -r cs201
/c/cs201/class
~/cs201
The idea, if your named folder doesn’t exist, is to force Zookeeper to start with a blank slate. Then you can register using the normal process.
The Zoo is a cluster of computers running the Linux operating system and sharing a common filesystem. Your userspace exists at /home/accts/<NetID>
. If your NetID does not appear in the /home/accts
directory, then you need to register (see above). This directory (in my case /home/accts/swk2
) is called the home directory and it has a shortcut or alias which is the tilde character, ~
. This is where you will find the cs201
directory that was created when you registered. Putting these two facts together, we can see that ~/cs201
is a logical place to keep your homework files.
Method 1 (GUI)
Head over to AKW and log in to one of the Zoo workstations on the third floor. Much like with Mac or Windows, you can access your files through the Linux desktop’s graphical user interface (GUI).
/c/cs201/handouts
or download them from the course homepage (under “Assignments”); N.B. the homework files are NOT available from ClassesV2The “Files” icon will look like a gray filing cabinet and once you double- click it, you will see a familiar file explorer format. You can click around and open Racket files in DrRacket, for instance. If you click on “Other Locations” and then “Computer”, you can see the root of the Zoo filesystem. Click on the folder labeled “c” to observe where the materials and code for each departmental course reside. The scripts you will use for submitting code are located in /c/cs201/bin
(so-called because it contains executable programs or “binaries”). You may not have permission to modify and/or read the files in this part of the Zoo, but it’s helpful to have a mental map of how everything fits together.
Within the file explorer, your “Home” directory will be available as a pinned folder visible in the navbar on the left. This is the graphical way of reaching ~
or “home.”
Method 2 (CLI)
Click on “Terminal” in your dock. I will be using “terminal” interchangeably with “shell”, “bash”, and “command line interface” (or CLI). The window that pops up will display a prompt such as bash-3.4$
or just $
next to a blinking cursor. By default, you will be in your home directory. cd
to cs201
to start working.
We will cover remote command-line access in a subsequent section.
One of the confusing things about the current Zoo configuration is that your prompt (the bash-3.4$
part) only gives information about the shell’s version and none about your current location, which is far more important. We will cover how to make the prompt more useful, but right now you will learn the most important basic command: pwd
(short for “print working directory”). Enter this command on the terminal and press Enter
. You should see the absolute path of your current location in the filesystem. “Absolute” means that the path starts at the root (represented by /
) and shows all the parent folders of your current folder. A “relative” path is defined by reference to the current working directory.
If you are using the terminal and get lost, just use pwd
to find your place.
If your terminal is cluttered with a bunch of unneeded text, type clear
to refresh it. Practice by invoking pwd
multiple times and then clear
-ing the display. This is a typical workflow: accumulate the output from several commands and then refresh the screen.
Now try cd
. If you enter cd
without any arguments, you will be returned to your home folder. This is a useful default, but the true power of the CLI is the ability to specify arguments and options (“flags”) for commands. The typical syntax for a command is: <program> <flags> <argument>
. You type these elements, each separated by a single whitespace, and then press Enter
.
The cd
command takes an argument that is the path to a directory. Thus you already know where the command cd ~
will bring you. Hint: it’s the same place as cd
invoked with no arguments (but why?). Now try this:
cd /c/cs201/bin
To check that you’re in the right place, use pwd
. See what we did? We gave an absolute path to cd
as an argument and then we moved to that path within the file system.
But moving around is useless without the ability to see the stuff located in our CWD. Use the ls
command to “list” the contents of the current working directory. If you’ve been following along and have moved to /c/cs201/bin
, you should see a bunch of scripts related to submitting and checking your homework files. ls
and cd
are to the CLI what the trackpad and cursor are to your laptop. Practice using them!
ls
brings up two new ideas. First, it is often convenient to invoke ls
with some additional features, or “flags”. Try running ls -al
. This should display for you the contents of the current directory, but listed in one column with extra details. Note that ls
can take an argument (the path to some other directory), but usually you will want to call it without an argument so that it defaults to show the contents of the current directory. The -al
part of ls -al
is not an argument, but rather two flags or options, each denoted by a lowercase letter (a
for “show all” and l
for “long format”). By convention, a hyphen precedes the flags, which are not ordered. That is to say, -al
is the same as -la
.
Suppose you are working in ~/cs201
but want to remember the commands available in the ZSS. Putting what we know together, we could type
ls -la /c/cs201/bin
and get a quick printout of the various submit scripts without having to leave our working directory in user-space.
The second idea flows out of what you see in the top three lines when you invoke ls -al
. Here’s an example:
total 32
drwxrwxr-x 6 swk2 swk2 4096 Jan 17 10:50 .
drwx------ 55 swk2 swk2 4096 Jan 10 16:43 ..
You can ignore the first line, which has to do with the memory blocks used by the current directory. The file named .
is a directory, as can be seen from the initial d
in drwxrwxr-x
. Don’t worry about this too much. In Linux everything is a file, so directories are just a special case of files. More importantly, the .
is a special shortcut just like the tilde ~
is. The .
is a symbolic link to the CWD. From this, we can reason that cd .
will “move” the shell into the current directory, or, right back where we started. This doesn’t seem helpful at all! But we will see an application later on.
The two periods ..
are a shortcut to the parent directory, or the folder “one level up” from where we currently are located. If you keep invoking cd ..
, you will eventually end up where? At the root of course! If cd ..
gives you a way to move upward, the typical way of moving “downward” is to ls
the contents of the CWD. Are there any subfolders? If so, then you can move “down” into them by running cd <name_of_folder>
.
Now is a decent time to discuss two vital features of your bash shell. Using the terminal without them is like trying to speak a language without the verb “to be.”
Hit the up-arrow
key to access prior commands, which will be displayed next to the prompt, ready for you to run them. This is handy for recalling long commands that would be a pain to re-type! The commands are stored in “stack” order such that the immediately previous command is the first accessed via up-arrow
. To see how many of your commands bash will remember, run
echo $HISTSIZE
Bash will autocomplete resource names once it has enough characters to disambiguate them. Huh? Let’s say we’re in ~
. We want to cd
into the cs201
folder. Type cd cs2
and then hit TAB
. What happens? Play around and you should be able to figure it out. You can also use tab completion to check for the existence of files or folders. Type /c/cs201/bin/un
and then press TAB
twice in a row. Bash will list all the files in /c/cs201/bin
that begin with the substring “un”. We can use this fact to check that the file we want to run as a program or specify as an argument actually exists in the location we expect it. If tab completion doesn’t find anything, we may be looking in the wrong place.
At least 50% of the errors that students run into with the ZSS arise from trying to run executables such as /c/cs201/bin/check
using the wrong path. Do NOT rely on cut-and-paste! Instead, always be mindful of your current location within the filesystem and use tab completion and ls -la
to ensure that the folder or file you want to work with actually exists at the location you are saying it does.
Here are some basic commands to practice. Can you get to any location on the Zoo without resorting to “Files” or the mouse? What man
and cp
do and what kind of argument(s) they take are left as exercises for the reader!
pwd
ls
ls -la
ls -la <path_to_folder>
man
man ssh
man cp
cp /c/cs201/handouts/hw0.rkt ~/cs201
cd
cd ~
cd /
cd <path_to_folder>
cd .
cd ..
The ONLY way to submit is using a Zoo terminal. In all likelihood, your error is that you are referring to a file that does not exist in the location you have specified.
Using relative or absolute filepaths, it’s possible to submit your Racket files from a location other than the directory in which those files reside. But it is not a good idea for beginners. So step one is to cd
over to the location of your homework file. By convention, this file will be named hw<as-no>.rkt
where <asno>
is just the number of the assignment.
Once you’re in the right location, you need to understand the difference between system-wide programs and user programs. /c/cs201/bin/submit
is a user program. It is a piece of code written by a professor and then compiled into a binary that can then do stuff on your files and the Zoo filesystem. You might ask why we can’t just type submit
, much in the way we type man
to invoke the manual program. man
and ls
and cat
and ssh
are all programs that ship with Linux or can be downloaded as system packages. They live in /usr/bin
and are in some senses privileged. When you run a command, the terminal automatically looks first in /usr/bin
to see if there’s a match for the name of program you are trying to invoke. System-wide programs like these can conflict with user programs by having the same name.
Suppose you write a script and call it man
. Bash will run the system-wide version every time, unless you run the script not with man
but with the path to where your “user” version exists. This is where the .
shortcut becomes handy. Say my version of man
is located in ~/cs201
and that’s in fact my CWD. I can run (assuming my man
is executable) the following:
./man
and the shell will know that it’s my version and not the one in /usr/bin
because I have specified that the program I want is located in the current working directory (a.k.a. .
).
You MUST give the absolute (or correct relative) filepath to /c/cs201/bin/submit
(or /c/cs201/bin/protect
, etc.) WHENEVER you invoke it. Use ls
or tab completion to make sure you have specified the path correctly. The intuition is that Yale’s Zoo Submit System is specific to the Zoo cluster and is thus a resource only available to you and the rest of the CS department and not the general Linux community. So we need to tell the shell exactly where this program exists. Furthermore, we can’t misspell anything or forget whitespace between arguments since the CLI is unforgiving in a way that a Google search, say, is not.
You must use this level of care and precision when referring to all files. So please go slowly. GO SLOWLY. Don’t copy-and-paste.
Rant over! Here’s how we would submit a Racket file for grading if our CWD is the folder in which the file exists.
/c/cs201/bin/submit <asno> ./hw<as-no>.rkt
From above, we note that the program takes two arguments (the order of arguments DOES matter, unlike with flags). The first is the assignment number, and the second is an accurate path to your homework file. In this case, the homework file exists in the CWD so we could also simply specify
/c/cs201/bin/submit <asno> hw<asno>.rkt
You should see a message saying that your submission was “copied” if you have done everything right and “not copied” if something went wrong. The syntax is exactly the same for the other submit scripts, which you can use to unsubmit your work or protect it or verify that you have indeed submitted file(s).
This guide is NOT the manual for the ZSS; rather, it attempts to demystify why the submit programs need to be invoked in the way they do. Again, you will learn so much more (and be able to check your work) if you commit to not copying-and-pasting the commands from the existing guide.
Even though it’s possible to do all your programming assignments on the Zoo workstations, you should really learn how to send files to the Zoo from a remote machine (e.g. your laptop) over the internet. There are less and more efficient ways of transferring files to your Zoo userspace. Remember that your code must first make it to your Zoo account before submission! /c/cs201/bin/submit
only exists on the Zoo cluster, to refer to it on your own computer makes no sense.
Less good ways of transferring files to the Zoo
Good ways of transferring files to the Zoo
ssh
/scp
(the best and easiest way, reinforces CLI skills)ssh
/git
(only if you know/like Git and are familiar with ssh keys)You may have tried to use some of the shell commands like ls
and cd
on your own computer. If you have a Mac, the program Terminal.app is accessible via “Utilities” within “Applications.” Once again, I recommend pinning the terminal to the dock for easy access. The Mac terminal works great because the Mac OS, like Linux, is based on the Unix operating system. So it follows all the same conventions and will have many of the same system-wide programs.
If you are running Linux you probably don’t need to be reading this quick-start guide (!) and you will of course have a Unix-style terminal built in.
If you are running Windows, then the situation is somewhat murkier. The Windows equivalent to terminal is called PowerShell. If you are running Windows 7 or earlier, you will have something called cmd.exe
but you should really update to Windows 10. Microsoft has promised to support ssh
in future builds, but right now, the only workaround is to use the Linux Subsystem for Windows. Since this is rather complicated, please write to the TF regarding your Windows setup or come to help hours. I am a Windows user so I’m happy to help you get set up! The many slight and annoying differences between Windows and *nix OS’s are not worth delving into here.
OK, so from here on I am assuming that you have a Mac. Now we can discuss what ssh
or “secure shell” does. Pause for a moment and type man ssh
in your terminal. It’s a bit intimidating, but it’s good practice. To scroll down in a man
page, use the j
key and to scroll up use k
. To exit, hit q
for “quit.”
If man ssh
or which ssh
doesn’t display anything, then you don’t have the ssh
utility on your machine and you should also email me or come to help hours.
ssh
is the protocol for logging into the Zoo cluster remotely. You must be connected to the internet to do this. You should memorize the following “magic incantation”:
ssh <NetID>@node.zoo.cs.yale.edu
The ssh
program takes an argument that is string consisting of a username “at” a particular host. For you, the username will always be your NetID and the host is ALWAYS node.zoo.cs.yale.edu
. You can remember this because each entity is a superset of the previous one. The space of all educational institutions contains Yale, which in turn contains Yale’s CS department, which contains the Zoo, which is ultimately composed of different nodes/workstations named after animals.
Easy, right? After running this command, you’ll be asked to enter your NetID password. You may be asked to type “yes” or “no” to trust/add the Zoo’s ssh
key to your list of known hosts. Go ahead and type “yes” or “Y” and then hit Enter
. If everything works, your shell will now turn into your shell on the Zoo. From here you will be able to use the submit scripts and the Zoo’s version of Racket. You can drop back into your computer’s shell by typing exit
.
We now have a way of getting you into the Zoo, but we still need to get your files onto the Zoo. Recall Prof. Angluin’s diagram of the two-step process for submission!
You could in theory ssh
into the Zoo from your computer each time you wanted to work on your code. This would mean using a text editor like Emacs or Vim and doing everything from the command line since it’s not possible to use DrRacket (or any other graphical program) when ssh
-ed in to the Zoo. A better workflow is to install the latest version of DrRacket on your computer and work locally (saving and backing up locally as you go). Then, when you have finished or reached a milestone in the assignment, you can transfer the file to the Zoo and then ssh
into the Zoo and submit that file.
The way to send a file from one host to another host securely is with scp
or “secure copy”. scp
is rather brittle when it comes to tab-completed file paths, so I recommend always following these steps. I will be using the file hw0.rkt
as the example filename.
cd
into the directory where hw0.rkt
residesscp hw0.rkt
and NOT ./hw0.rkt
or /abs/path/to/hw0.rkt
(scp
may incorrectly try to force the name of the file to be ./hw0.rkt
in the target folder since Linux is very permissive re: what filenames are allowed)<NetID>@node.zoo.cs.yale.edu:~/cs201
Enter
; if all goes well, you’ll be prompted for a password and see this:swk2@node.zoo.cs.yale.edu's password:
hw0.rkt 100% 20KB 19.5KB/s 00:00
N.B. that Linux will hide your typing when you enter a password. If you’ve made a typo, you can still use Backspace
. If you don’t see the statistics about the transfer size and rate, the transfer has not succeeded and you will need to try again. The full command is:
scp hw0.rkt swk2@node.zoo.cs.yale.edu:~/cs201/
note the subtle differences between this and ssh
. With scp
you ALSO need to specify the target directory on the host. This is the part after the colon in user@host:target
(no spaces). So in my example, the target is ~/cs201/
, which is the cs201
folder in my home directory. Only send files to your user-space on the Zoo! That is, your home folder ~
and its sub-folders.
As soon as you transfer files, you should ssh
into the Zoo and check that they have arrived as intended.
Research the commands touch
, mkdir
, rm
, and mv
. These are essential. Often you will want to move a file from one directory to another without leaving the CLI. mv
can do this as well as rename a file or folder.
mv <file> /path/to/new/folder
mv <old_file_name> <new_file_name>
Be careful with rm
, particularly when called with the flags for “recursive” and/or “force” (-rf
). In what situations are these flags necessary? In what situations might they be very dangerous? Don’t use them without finding out!
To practice with mv
and rm
, you can create an empty file with the touch
command. To see how touch
should be invoked, use man
! You can easily delete the file with rm
. Here are the terminal commands you should now review:
pwd
ls
cd
man
mv
mkdir
cp
rm
ssh
scp
touch
racket
and for good measure, two new ones:
less
cat
For 201 students, I recommend doing your programming in DrRacket in your own desktop GUI environment and only using the terminal to send files to the Zoo and then ssh
into the Zoo in order to submit and check on those files.
However, it’s a good idea to start learning a CLI editor. I recommend Vim. But this is a matter of eternal debate :) The important thing is to test a few out. Vim should come preinstalled in the /usr/bin
of your Mac and can thus be called with vim
from the terminal. The Zoo machines will of course have many editors available (vim
, emacs
, nano
, etc.).
Use TextEdit or DrRacket if you need to edit your code on the Zoo machines.
autograde
program?Once the public tests are made available for an assignment, you can test your code against them by cd
-ing to the directory in which your Racket file lives and running the autograder with the special “test” flag set:
/c/cs201/bin/autograde --test <as-no>
The “public tests” are simply the example procedure applications given in the comments of the homework file. As you write your code, you should be using the REPL to make sure your procedures are returning the same values as the desired outputs listed by Prof. Angluin.
It’s also a good idea to test your code with different inputs, but the focus of the course is not on handling “corner cases” or adversarial inputs. If you’re asked to write a procedure that operates on a list of non-negative integers, you can be confident that you will not receive a list with elements that are negative or of a different type altogether.
Before anything else, check that you have submitted a file and that it is the correct file. Use /c/cs201/bin/check
for the existence of a submission. This script basically just runs ls -la
on the SUBMIT directory where your code is sent for grading.
Suppose you submit hw0.rkt
but then need to submit a newer version. Or suppose that you cannot remember if you have submitted the new version. In the latter case, you can examine the files’ sizes or last-modified times to verify that the submitted file is in fact identical to the file that’s been submitted. But this is slightly beyond the scope of the quick-start guide.
To avoid all such confusion, I suggest the following practices:
<asno>
argument to the submit programs matches the <asno>
on your homework file!hw3.rkt
, for instance, with /c/cs201/bin/submit 2 hw3.rkt
and Homework 2 has not been graded yet, the submission of the third assignment to the second assignment’s submit folder will create a new, later timestamp and make it seem as if your Homework 2 submission is now very late; please email the TF/professor if you think you’ve made such an error (it’s no big deal, we just want to make sure we have the right code and late days recorded for you!)/c/cs201/bin/unsubmit
/c/cs201/check
to make sure that your submitted work folder is now emptyAlternatively, your functions may be perfect, but an omitted parenthesis or missing semicolon before a comment will make your Racket file uninterpretable. To catch syntax errors of this kind, try running the Zoo’s built-in Racket interpreter on your file:
racket hw<asno>.rkt
Any function applications or calls to (display)
should evaluate and be shown on the screen. Or if your file consists only of function definitions (as will most often be the case), nothing will print out. If you see an error message, go to the line mentioned in the error and investigate. This means there is some kind of syntax error. Don’t submit until your file is error-free!
In particular, if you are not able to complete a certain problem in a homework, make sure that the definition for that function is syntactically correct! Just return the empty list or 0 or a placeholder string/symbol. Check that the parentheses are balanced!
In a Unix environment, preferences for a program can often be set by adding statements to a special configuration file. In the case of bash, the “config” file is just a text file that lives in your home directory ~
. Trickily, this file is also what’s called a “dot file” because its name begins with a dot:
~/.bashrc
Dot files are normally hidden, so to see this file, run ls
with the -al
flag to show ALL files (dot or otherwise). Now you can open it in the text editor of your choice. If you’re trying to do this at the physical Zoo using a graphical text editor, you might not be able to view dot files using the “Files” explorer. From the terminal, you can run
gedit ~/.bashrc
to open up the config file in a GUI text editor.
There are many online resources on how to supercharge your bash profile, but we will keep it simple for now. We just want to set the prompt (the dollar sign or bash3.4$
part) to show our username and the CWD.
After making some space at the top of .bashrc
, input the following statement on its own line:
PS1="\u@\w$ "
PS1
is just a variable that in the world of the configuration file refers to the prompt. We are setting it equal to a string (strings are enclosed in quotes). The structure of this particular string is:
\u
(an escape sequence for “user”)@
(the “at” symbol; like the dollar sign, this is just shell convention)\w
(an escape sequence for “working directory”)$
(the dollar sign followed by one whitespace, so that our commands don’t bunch up against the prompt)This will result, in my case, in a bash prompt that looks like
swk2@~$
and from this I can instantly see that I (swk2
) am currently located in my home directory ~
. When I move around in the filesystem, the prompt will follow me and this is a much better state of affairs! If you are unfamiliar with escape sequences or the use of the backslash to indicate non-printing or special or ambiguous characters, don’t worry to much. These don’t really come up in Racket programming (of the kind done in this course at least). But have a look online to get a sense of what sequences like \n
or “newline” mean. If you want to further customize your prompt, consult:
http://tldp.org/HOWTO/Bash-Prompt-HOWTO/bash-prompt-escape-sequences.html
Once you save the .bashrc
file with this new line, you can see your new prompt by either exiting bash and restarting, or running source ~/.bashrc
. You will probably only need to modify your .bashrc
on the Zoo, since the default prompt for Mac’s Terminal.app is pretty sensible.
There’s a final nuance to this, which is that there are different configuration files for bash depending on whether or not you are using it interactively or as a login shell. When you ssh
into the Zoo, bash is being run as a log-in shell and thus uses the .bash_profile
config file instead of .bashrc
. The converse holds for when you are “interactively” using bash while programming at a Zoo workstation in person.
Fortunately, there’s a quick fix! Just make your .bash_profile
identical to your .bashrc
by inputting and saving the following line at the top of your .bash_profile
:
source ~/.bashrc
This means when you log in to the Zoo remotely, bash will look in ~/.bash_profile
and then import the contents of ~/.bashrc
into .bash_profile
, making sure that your new and informative prompt is defined!
If you can’t find ~/.bashrc
or ~/.bash_profile
in your home directory, you should either ask for help or create the files with touch
before editing them.
Because it makes the TF’s life very difficult! When you use certain graphical or debugging features in DrRacket, your file will no longer be in plain old ASCII format. So when I look at your code in my text editor (say, to see if partial credit should be awarded!), I will see a file that is thousands of lines long and mostly full of strange XML formatting metadata. Run cat
on your file and check that what prints out to the terminal is the normal text of your file (without any extra encoding).
.bak
file and do I need to submit them as well?Depending on your operating system, DrRacket may generate the file hw<as_no>.bak
in addition to hw<as_no>.rkt
. This is just a “backup” file so you should not submit it. The instructions at the top of each homework assignment will clearly specify the name of each file you should submit.