$20
This assignment refers to a setup page which can be found on Blackboard under the Miscellaneous section. In particular, you should get visit the vi cheat sheet, Unix cheat sheet, vim tutor, and ssh download if you are planning on using Windows to connect to the department machines.
Steps
Log in to Linux
Go to the CS Department lab at NPB 2.118. If working remotely, see how to log in remotely on the setup page and skip to step 1(e).
There are two types of workstations in the lab:Dell Thin Client - (left side of lab) These access the VDI (like the machines in the classrooms). To use them, see the instructions on the setup page.
Linux Workstations - (right side of lab) These run Ubuntu 14.04 and are ideal for the work you will do in this course.
Using a Linux workstation, log in using your abc123 Your password will be defaulted to your UTSA banner ID without the @.
Open a terminal window. From the desktop menu, use ApplicationsAccessoriesTerminal or ApplicationsAccessoriesLXTerminal
Since you are using a temporary password, change your password using the passwd (Note that the “$” is being used to indicate that the Linux shell is prompting you for input). The actual prompt may look different (e.g., your user ID). In the terminal window, type (without the “$”):
$ passwd
Notes: If you are logging in remotely, do the following instead:
If using Linux:
– Start a terminal window and enter the following command:
$ ssh abc123@foxii.cs.utsa.edu
(where abc123 is your abc123 and ii is one of 01 through 06)
If using Windows:
You should install ssh (see the setup page).
You can transfer files with an sftp client (not ftp)
For both, you will specify abc123@foxii.cs.utsa.edu to connect (where abc123 is your abc123 and ii is one of 01 through 06)
In the future, consider using a virtual machine (e.g., VirtualBox), dual boot, or Cygwin.
Create a directory for this course and copy important course files to it. (You may want to check the Unix Cheat Sheet for help here).
After logging in, check your current directory using the print working directory command:
$ pwd
See what files are in your current directory:
$ ls -al
(This will show all files and give long details on them. You will notice “hidden” files beginning with a “.”.)
(c) Create a directory for this course:
$ mkdir ~/courses/cs3423 -p (d) Change to your cs3423 directory:
$ cd ~/courses/cs3423
(You should verify that you are in the directory with the pwd command.) (e) Copy the course materials to your directory:
$ cp /usr/local/courses/rslavin/cs3423/* . -r
(You should verify that the material was copied by using the ls command.)
Use the vi editor to create a simple shell script.
(a) Study the vi Cheat Sheet from the setup page. (b) (optional) Try the vi tutorial:
$ mkdir ~/tmp 2 /dev/null; cd ~/tmp $ vimtutor
(follow the instructions)
(c) If you haven’t already in a prior course, create a .vimrc file to set up defaults in vim for indention and line numbers.
$ vi ~/.vimrc
:set
ai sw=4
:set
number
:set
expandtab
:set
softtabstop=4
:set
smartindent
(d) Create your first script for this class using vi. Note: Be careful to type each character, including spaces, exactly as it appears below. Copying and pasting will not preserve spaces correctly.
$ cd ~/courses/cs3423
$ mkdir assignments
iii. $ cd assignments iv. $ vi cs3423a0
Enter the following code exactly as it appears.
#!/bin/bash
if [ $# -ne 2 ]; then
echo "usage: $0 <firstName <lastName" exit 1
fi
echo "My name is $1 $2"
echo "I am running this script from `pwd`" echo "My username is `whoami`" echo "I am logged in to `hostname`"
Exit your text editor and make your script executable:
$ chmod u+x ./cs3423a0
Execute your script and verify the output. In the command below, replace myFirstName and myLastName with your actual name.
$ ./cs3423a0 myFirstName myLastName
It should print the following:
My name is myFirstName myLastName
I am running this script from /home/myUsername/courses/cs3423/assignments
My username is myUsername
I am logged in to myHostName
You now need to save the output of your script by redirecting the output to txt.
$ ./cs3423a0 myFirstName myLastName a0Out.txt
Zip all your deliverables into a single zip file for turning in. Your zip file’s name should include your abc123 ID using the format in the command below. You will do this for all assignments going forward.
$ zip -r abc123.zip cs3423a0 a0Out.txt
Upload your results to Blackboard.
Visit http://utsa.blackboard.com.
Log in with your abc123 id and passphrase.
Blackboard will show a list of courses. Select CS3423 (not the recitation).
Locate Assignment 0 under Assignments
Follow the directions on the screen to upload your zip file.
Note: If you created your script and zip file remotely via ssh, you will need to use either an sftp client or the scp command to move the files from the remote machine to your local one.