#!/bin/sh
#demoShellScript.sh  P. Conrad, CISC181, Spring 2005

# first line of a shell script must start with #! followed by the 
# full path to the exectuable file for the shell being used to interpret
# the script.  In this case, "!#/bin/sh"

# lines starting with # are comments
# other lines are either unix commands, control structures
# in the /bin/sh language, assignments to variables, etc.

# Set location of CURL utiltity

CURL=/home/usra/d9/55560/local/bin/curl

# if there are more than two arguments, complain
# "echo 1>&2"  echoes output to stderr instead of stdout
if [ $# -gt 2 ]; then
         echo 1>&2 Usage: $0 time date
         exit 127
fi

# set the TIME variable to 9am if no time specified
# otherwise set the TIME from the 1st argument

if [ $# -lt 1 ]; then
   TIME=8am
else
   TIME=$1
fi

# set the DATE variable to the current date if
# no date specified, otherwise set to 2nd argument

if [ $# -lt 2 ]; then
   DATE=`date '+%m.%d'`
else
   DATE=$2
fi

NOTES_URL=http://udel.edu/~pconrad/cisc181/05S/lect/notes/$TIME/$DATE
CODE_URL=http://udel.edu/~pconrad/cisc181/05S/lect/code/$TIME/$DATE

$CURL -f $NOTES_URL 1>/dev/null 2>/dev/null

if [ $? -eq 0 ]
then
  echo "Notes directory for $TIME/$DATE is available online"
else
  echo "Notes directory for $TIME/$DATE is not available online"
fi

$CURL -f $CODE_URL 1>/dev/null 2>/dev/null

if [ $? -eq 0 ]
then
  echo "Code directory for $TIME/$DATE is available online"
else
  echo "Code directory for $TIME/$DATE is not available online"
fi



