CS 4010 Spring 2019

Lab 4

Find a computer and log into the OSX side using your CS login name and password.

Open Firefox and find the class web page.

Open TextWrangler - use the finder window and go to applications.
Open a new text file, called Lab4.txt, to record your work today - you will paste in some of your command lines. The header of the file should look like:
Your Name
CS 4010
Lab 4
February 25, 2019


Find the Terminal - use the finder window and go to applications and then utilities.

How to change your shell to bash and create .bash_profile

If you have not already done this, here is a way that users can change their terminal to bash:
chsh -s /bin/bash
Then you have to enter your user password and open a new terminal window to see the changes.

How-to create a bash_profile:
Start up Terminal
Type "cd ~/" to go to your home folder
Type pwd to make sure you are in your home folder THIS IS VERY IMPORTANT
Type "touch .bash_profile" to create your new file.
Edit .bash_profile with nano, pico, or TextWrangler.
Type "source ~/.bash_profile" to reload .bash_profile and update any functions you add. (You can also open a new terminal window.)

Now we will add three things to your .bash_profile:
A path to your scripts directory
A noclobber statement
An alias to your sandbox
Be sure to past each command you use into your Lab4.txt file.

A path to your scripts directory:
Check your existing path:
echo $PATH

Adding to the path in your .bash_profile you can edit your bash profile using pico .bash_profile you will need to modify the path shown below:
PATH="${PATH}:/Users/mmartin/teaching/Spring_2018/4010/Book/pcfb/scripts"
export PATH
Check your path again to see that it was added correctly

A noclobber statement
This changes the system settings to give you a warning before cp, mv, and > overwrite files.
See the box at the bottom of page 87.
Edit your bash profile using pico .bash_profile  to add the line shown below:
set -o noclobber

An alias to your sandbox
This will allow you to use a shortcut for long commands - see page 99


Now we want to write scripts:
Write a script: the goal is to create and run the script on page 89 to list the directory contents.
Copying file in bulk: work through the example starting on page 92

Automating curl to retrieve literature references: if you have time work through example starting on page 97


Turn it in:
Go to the CS Homework Submission System: https://www.cs.csustan.edu/cshomework/
Choose: instructor Martin
              Spring 2019
              CS4010
              Lab4
Upload the your Lab4.txt file as prompted.