The purpose of this lab is to teach some more advanced shell commands. After you finish this lab, you will be able to search for files and text, and be able to further learn any command desired.
Before starting the lab, OPEN THE REFERENCE SHEET
Depending on your working environment, perform the appropriate action:
Environment | Action |
---|---|
Linux Lab Machine | Open a terminal window |
Windows or Personal Computer | SSH into data.cs.purdue.edu * |
* You must have X11 forwarding enabled. If you are on the Windows Lab Computer, follow the instructions below:
- Search for 'Xming' in the start menu and run it.
- Open PuTTy
- Expand the 'SSH' tab from the 'Category' list
- Choose 'X11' from 'SSH' list
- Check 'Enable X11 Forwarding'
- Connect like normal to
data.cs.purdue.edu
within PuTTy.
cd; curl -sL https://raw.githubusercontent.com/PurdueCS190/lab3/master/lab3init | /bin/bash
Copy the command above and run it within the terminal. It will create a folder named cs190lab3
located within your home directory.
This section is just like the last lab. You are given tasks that each have:
- a working directory you must 'cd' into
- desired action that can be performed using a one line command in the terminal
- a terminal command that is limited to
- a single base command (cp, mv, rm, etc...) or multiple base commands chained together by pipes (
|
) - a single line
- a single base command (cp, mv, rm, etc...) or multiple base commands chained together by pipes (
Working Directory: your home directory
File URL: https://raw.githubusercontent.com/PurdueCS190/lab3/master/answers.txt
Desired Action: download the answers.txt file from the URL above using the terminal
(may not use browser!)
Record your answer under the Task 1 block.
Your answers.txt file is now located in your home directory at ~/answers.txt
. You can open this file up in pluma by typing the command below.
pluma ~/answers.txt &
Working Directory: ~/cs190lab3/
Command: bash madlib
Desired Action: run the Bash program named 'madlib' by using the command above
and complete each prompt.
You do not need to copy anything over to answers.txt for Task 2a.
Working Directory: ~/cs190lab3/
Command: bash madlib
Desired Action: run the Bash program named 'madlib' by using the command format above,
but you must feed the program the contents of 'input.txt' AND
save the output of the program to a file named 'poem.txt'.
Record your answer under the Task 2b block.
Once you've saved the output of MadLib in poem.txt, you can confirm there is text by running
cat poem.txt
.
Working Directory: ~/cs190lab3/
Desired Action: search through the text file "The Young Engineers.txt" for occurrences
of the word "horseman". Have the output line numbers of each occurrence.
# format of output
XXXX:this is the word horseback appearing in text
XXXX is the line number
Record your answer under the Task 3 block.
Students in CS180 primarily use the application DrJava to write and edit their Java files. It is a wonderfully simple editor and is also free and open source. This means that we can download the source code of the project, edit it to fit our needs, then rebuild the application.
In the next section, we will be changing a String value within the DrJava source code that appears when quitting the application. We will then rebuild the source and test our changes to confirm it worked.
First you need to get the DrJava source code. Run:
svn co https://drjava.svn.sourceforge.net/svnroot/drjava/trunk/drjava
Working Directory: ~/cs190lab3/drjava
Phrase: "Untitled file has been modified. Would you like to save it?"
Desired Action: print out the file(s) and line number where the phrase above appears
within the working directory. You need to search through the drjava
folder and ALL of its subdirectories (recursive search).
Record your answer under the Task 4 block.
ALSO: Record the file path (ex. drjava/src/.../filename.java) and the line number (ex. 1000)
Working Directory: ~/cs190lab3/drjava
-
Open the FILE FOUND IN THE PREVIOUS TASK and navigate to the line number in pluma by running the command below.
pluma <file_path> +<line_number> # example: open DrJava.java in pluma and scroll to line 349. pluma drjava/src/edu/rice/cs/drjava/DrJava.java +349 &
-
Replace the string
"Untitled file has been modified. Would you like to save it?"
with"YOU FORGOT TO SAVE YOUR FILE!!!"
-
Save the file
-
Tell ant where Java 8 is
export JAVA8_HOME=/opt/oracle-jdk-bin-1.8.0.20/
-
Recompile DrJava by running the command
cd ~/cs190lab3/drjava; ant jar
-
Run the new DrJava by running the command
java -jar ~/cs190lab3/drjava/drjava.jar
-
Type anything into the main text area, and then quit DrJava to see your new message!
Please load your answers.txt file in a text editor and show the TA your modified DrJava dialog box.
If you find any bugs within the code or misspellings in the write-up, please tell the TA. Thanks!