Please take a look I am stuck on step 4
- The problem statement, all variables and given/known data:
#!/bin/bash
### ULI101 - ASSIGNMENT #2 (PART A) - DUE DATE Wed, Aug 3, 2011, before 12 midnight.
###====================================================================================
### Create a2 directory in your home directory. Do everything for this
### assignment in your a2 directory.
### Create a directory called "Pictures" in your a2 directory. Copy all files from
### URL to your ~a2/Pictures directory.
### This directory contains 10 image files, along with a text file called a2 (this file),
### which you will edit using vi, and add commands that do what is being asked in the comment lines
### When this script is run, one parameter/argument is passed to the script.
### This parameter/argument should consist of the last 3 digits of your student id
### STEP 1
### ======================
### Make sure that the parameter/argument entered by the user consists of 3 numbers.
### If its not 3 numbers, then give appropriate error message and exit with exit status of 1.
### If the parameter entered was a 3 digit number, then Display it
### STEP 2
###=======================
### Check if ~a2/Pictures directory exists in your home directory.
### If this directory is not found, give an appropriate error msg and exit with exit value of 2
### If this directory exists, then go to the next step and do not display any error msg
### STEP 3
### ======================
### List all files that exist in your ~a2/Pictures directory
### STEP 4
###==========================
### Use each of the 3 digits that you entered as parameter
### (last 3 digits of your student number) and copy the appropriate files
### from the Pictures directory to ~/public_html directory
### These will be used in part B of this assignment when you create your webpage.
### If your last 3 digits were 123, then you will copy files starting with:
### linux-pic1, linux-pic2, linux-pic3 to your ~/public_html directory
### HINT: use 'cut' command to extract each of the 3 digits
### HINT: use a loop to copy the 3 appropriate files
### STEP 5
### ============================
### In ~/a2/Pictures directory, set permissions of all image files
### that start with 'linux-pic', such that 'owner/user' has read
### and write permission, 'group' has none, and 'others' have read permission only.
### Once you have changed the permissions, list them so it shows what
### permissions they have now
### STEP 6
###==============================
### Create 3 empty files in your ~/a2/Pictures directory, each corresponding
### to one of the 3 digits from your student-id that you passed as a parameter/argument
### STEP 7
###=================================
### Part (1):
### Display all the non-hidden files in your ~/a2/Pictures that have a
### filename that consists of one digit only
### Part (2):
### Now use a command to do a count of files you found in part (1)
### STEP 8
###===============================
### Create a basic webpage in ~/a2 directory
### This can be a basic 'html' page for now, and in part B of this assignment,
### you will convert this into an 'xhtml' page
### This webpage should have :
### - a title (use <title> tag) that says 'My webpage'
### - a 'body' (use <body> tag) in which should say 'This is my basic webpage'
### Your webpage should be called "mypage123.html" where you need to
### replace 123 with the last 3 digits of your student number
### HINT: use 'here document' to write data into an html file
### HINT: Before you create the webpage, make sure you delete the
### existing webpage if it exists
### STEP 9
###============================
### Make sure the mypage123.html has been created
### and display the file pathname for it
### Now display the contents (code) of the webpage that you just created
### STEP 10
###==============================
### Now in your ~/public_html directory, please create a subdirectory
### called assign2, into which you will copy certain files
### (first check if this directory exists already, and if it does, delete it)
### Now copy the following files from your ~/a2 directory to ~/public_html/assign2:
### - all files whose filename starts with 'linux-pic' followed by one of the 3 digits
### that make up last 3-numbers of your student id (eg. if last 3 digits of your
### student id are 1, 2 and 3, then you will copy linux-pic1*, linux-pic2* and linux-pic3*
### - the html file that you created in the step above
### Now list all files that you have copied into ~/public_html/assign2
### Submit your assign2 (part A) by doing the following:
### 1) Put contents of your script into 'myresult' file (HINT use 'cat' and redirection)
### 2) Now run your assignment#2 with the appropriate parameter (last 3 digits of your student number)
### and redirect the output and append to 'myresult'.
### 3) Now that 'myresult' contains your code for the script as well as the result of
### running your script, you can send it to your professor by using the 'mail' command.
### 4) You must use the following subject line: ULI101A Assign2
###
### The assign2 (Part B) will be released next week and in that you will use the webpage
### that you created through this script, and will modify it.
-
Relevant commands, code, scripts, algorithms:
-
The attempts at a solution (include all code and scripts):
### STEP 1
### ======================
#set my student ID
set studentid=106
echo -n "Enter the last 3 digits of your student id:"
read studentid
if test "$studentid" -eq 106
then
echo $studentid
elif [[ "$studentid" != ^[0-9][0-9][0-9]$ ]];
then
echo "Please enter the last 3 digits"
exit 1
fi
### STEP 2
### =======================
dir=a2/Pictures
if [ -d "$dir" ];
then
echo -n "$dir exists.
"
elif [ ! -d "$dir" ];
then
echo -n "$dir doesn't exist"
exit 2
fi
### STEP 3
### ======================
ls ~/a2/Pictures
### STEP 4
###==========================
1=~/a2/Pictures/linux-pic1-clustertux.gif
2=~/a2/Pictures/linux-pic0-baby-penguin.png
3=~/a2/Pictures/linux-pic6-business.jpg
for first in $1
do
cp $1 ~/public_html
done
- Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):Seneca College, Toronto, Don Frray, ULI101
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).