help!!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help!!!
# 1  
Old 08-11-2010
help!!!

Can somebody please help me with my assignment? I went to all lectures and everything but I still don't get it. The items marked TO DO is what needs to be complete can somebody at least get me started? Thank you.


Code:
###############################################################################
# DO NOTE REMOVE OR CHANGE THIS BLOCK
# ASSIGNMENTS WITHOUT THIS BLOCK INTACT WILL NOT BE GRADED
#
# ULI101 - SUMMER 2010 
# ASSIGNMENT 2 BY: Sukhjot Khaira
# skhaira1@matrix.senecac.on.ca
#
# BIGBROTHER COMMAND VERIFIES THAT YOU COMPLETED THE WORK INDEPENDENTLY
# BY RECORDING STATISTICAL DATA ABOUT EXECUTION OF YOUR ASSIGNMENT SCRIPT
# IF YOU DELETE OR DAMAGE THE COMMAND BELOW BY ACCIDENT, YOU CAN RETRIEVE
# THE ORIGINAL FILE BY ISSUING THE ASSIGNMENT START COMMAND AGAIN
bigbrother 405c9e5a51dc056a608af15e3dc76be8ad3a1c05
###############################################################################

# TO DO: Check if the required argument (URL) is provided
#        Display an error message and exit with status 1 on error
# HINT:  check if $# is less than 1
if [ ]
then
        echo
        exit
fi

# Check if the parameter starts with http:// or https://
echo "$1" | grep -E "^https?://" > /dev/null
if [ $? -ne 0 ]
then
        echo "The URL must start with \"http://\" or \"https://\""
        # TO DO: Set the exit status to 2
        exit
fi

# Download and preprocess the page, download all images and create thumbnails
# Also, create HTML markup for thumbnails
# All files will be stored in ~/uli101.a2/tmp/
# Check the assignment description on the course website for more details
uli101.a2.getfiles "$1"

# Find out the server name and path 
# This is what appears in the URL after http:// 
# This is the directory to be created
# TO DO: Use the cut command to accomplish the above
# HINT:  Cut the third field using / as delimiter 
directory=$(echo "$1" | )

# Delete report directory from previous run - get a fresh start
rm -r ~/public_html/aggregator/$directory 2> /dev/null

# Create the report directory based on the URL
# TO DO: Create the directory where the report files will be copied into
# HINT: You need to re-create the directory deleted above

# Set the path to the report file
# The output file is always called index.html
output_file=~/public_html/aggregator/$directory/index.html

# Begin the report - HTML page headings
cat << TOP > $output_file
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
        <title>ULI101 Aggregator Report Page</title>
        <style type="text/css">
                body
                {
                        # TO DO: Set parameters such as font and colours for your report pages
                        #        PLEASE be unique - do not just copy the values from the example or your lab
                }
        </style>
</head>
<body>
<h1>Page summary</h1>
<ul>

TOP

# Find out the file size
# TO DO: Finish the cut command
# HINT:  You need to extract the size value using a space as a delimiter
size=$(ls -lh ~/uli101.a2/tmp/input.html | cut )
echo "<li>File size: $size</li>" >> $output_file

# TO DO: Count the lines in the file and append the result to the report
# HINT:  Use cat, wc and cut commands on input.html
#        FIGURE THIS OUT ON THE COMMAND LINE FIRST

# Count the number of HTML headings in the file and append result to report
headings=$(grep -ci "<h[1-6]" ~/uli101.a2/tmp/input.html)
echo "<li>Number of headings: $headings</li>" >> $output_file

# TO DO: Count out the number of paragraphs and append result to report
# HINT:  Use grep as above to match "<p[ >]"

# TO DO: Count out the number of hyperlinks and append result to report

# TO DO: Count out the number of <br> tags and append result to report
# HINT:  Use grep as above to match "<br[ >]"

echo "</ul>" >> $output_file

echo "<h1>Images</h1>" >> $output_file
echo "<p>" >> $output_file

# TO DO: Append the entire thumbnails.html file to the report
# HINT:  Use the cat command and >> redirection

# TO DO: Move all thumbnails from ~/uli101.a2/tmp/ to the report directory
# HINT:  The destination is: ~/public_html/aggregator/$directory

echo "</p>" >> $output_file

# TO DO: Add a hyperlink to the original page to the report
# HINT:  The hypelink is stored in $1. Use echo and >> redirection

cat << EOV >> $output_file
<p>
# TO DO: Add validation markup for XHTML and CSS
# HINT:  Copy and paste the markup from Validator website or your labs
#        Do not change what's given by the Validator
</p>

EOV

# TO DO: Add current date to the report
# HINT:  Use the date command 
echo "<p>Page aggregated on: ???</p>" >> $output_file
echo "</body>" >> $output_file
echo "</html>" >> $output_file

# Print the output line to the console
# This is the only output printed to the console for the entire script
# TO DO: Provide all values as required, tab-separated
# HINT:  Use variables that store the various grep/wc etc. results from above
echo -e "$1\t"


Last edited by pludi; 08-11-2010 at 04:40 PM.. Reason: code tags, please...
# 2  
Old 08-11-2010
  1. Homework goes here, under these rules.
  2. Use a descriptive title. "help!!!" doesn't tell anybody what it's about, and most people won't take a second look
  3. Show some initiative. Just asking for help without telling what you've tried and where you're stuck makes you come across like a lazy student who hopes that others do their work. We won't.
  4. When posting code, please use [CODE][/CODE] tags around these parts. That renders it more readable and any indentations are preserved.
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question