In CSE 160, you use two tools to run Python programs: Canopy and the command-line shell. This is a small guide in using the shell.
The command-line shell, sometimes called the command prompt or the terminal, is a tool that lets you control your computer using only textual commands. It offers a lot of power and simplicity (simplicity is different from ease of use).
Just like with a graphical file browser such as the Finder or Windows Explorer, there is a "current directory" that you are currently working in. ("Directory" and "folder" are synonyms.) You can issue commands that operate in that directory, or you can change the current directory.
This guide presents an example transcript of using the shell for Unix (Mac/Linux) and Windows machines. The transcript assumes that the student has already installed the Enthought Python Distribution as described in the Computing Resources page, and has used other programs such as the Finder or Windows Explorer to download his/her homework into a directory. When you run similar commands, there may be slight differences from the example transcript, such as the number, names, and times of files.
See the section that is relevant to you:
Here are most of the commands you will need to use:
You can open a command-line shell by running the terminal program.
In the below example transcript, $ is the prompt at which the user types commands. Boldface text was typed by the user, and non-boldface text was printed by the command-line shell.
$ pwd
/home/me
$ ls
Desktop Downloads Music Pictures Public Templates Videos
Documents Dropbox Old Programming Software Ubuntu One VirtualBox VMs
$ cd Desktop
$ pwd
/home/me/Desktop
$ ls
CSE160
$ cd CSE160
$ pwd
/home/me/Desktop/CSE160
$ ls
homework1 homework2
$ cd homework2
$ pwd
/home/me/Desktop/CSE160/homework2
$ ls
answers.txt data dna_analysis.py expected_output
$ python dna_analysis.py data/test-small.fastq
GC-content: 0.3
Here are most of the commands you will need to use:
You can open a command-line shell by running the cmd program.
You
should have a Command Prompt shortcut located in the Start Menu, in the
Accessories submenu of All Programs, or on the
Apps screen for Windows 8.
About.com has more detailed instructions about starting the command prompt.
In the below example transcript, text such as C:\Users\Me> is the prompt at which the user types commands. Boldface text was typed by the user, and non-boldface text was printed by the command-line shell. Also note that in this example transcript, much irrelevant output has been suppressed in order to emphasize the important information.
C:\Users\Me>echo %cd% C:\Users\Me C:\Users\Me>dir Directory of C:\Users\Me 06/02/2012 08:11 PM <DIR> . 06/02/2012 08:11 PM <DIR> .. 07/18/2012 05:03 PM <DIR> Contacts 01/10/2013 07:24 PM <DIR> Desktop 07/18/2012 05:03 PM <DIR> Documents 01/09/2013 09:59 PM <DIR> Downloads 07/18/2012 05:03 PM <DIR> Favorites 07/18/2012 05:03 PM <DIR> Links 07/18/2012 05:03 PM <DIR> Music 11/28/2012 09:19 PM <DIR> Pictures 11/29/2012 01:42 AM <DIR> Saved Games 07/18/2012 05:03 PM <DIR> Searches 11/27/2012 09:06 PM <DIR> Videos C:\Users\Me>cd Desktop C:\Users\Me\Desktop>dir Directory of C:\Users\Me\Desktop 01/10/2013 07:25 PM <DIR> . 01/10/2013 07:25 PM <DIR> .. 01/10/2013 07:25 PM <DIR> CSE160 C:\Users\Me\Desktop>cd CSE160 C:\Users\Me\Desktop\CSE160>dir Directory of C:\Users\Me\Desktop\CSE160 01/10/2013 07:25 PM <DIR> . 01/10/2013 07:25 PM <DIR> .. 01/10/2013 07:25 PM <DIR> homework1 01/10/2013 07:24 PM <DIR> homework2 C:\Users\Me\Desktop\CSE160>cd homework2 C:\Users\Me\Desktop\CSE160\homework2>dir Directory of C:\Users\Me\Desktop\CSE160\homework2 01/10/2013 07:24 PM <DIR> . 01/10/2013 07:24 PM <DIR> .. 01/06/2013 05:28 PM 519 answers.txt 01/10/2013 07:24 PM <DIR> data 01/09/2013 09:26 PM 1,866 dna_analysis.py 01/10/2013 07:24 PM <DIR> expected_output C:\Users\Me\Desktop\CSE160\homework2>python dna_analysis.py data\test-small.fastq GC-content: 0.3