Added some sample bash scripts to the UNIX102 page.
authorElana Hashman <ehashman@csclub.uwaterloo.ca>
Thu, 8 Mar 2012 21:10:04 +0000 (16:10 -0500)
committerElana Hashman <ehashman@csclub.uwaterloo.ca>
Thu, 8 Mar 2012 21:10:04 +0000 (16:10 -0500)
common.mk.in
unix102/Makefile
unix102/appender.sh [new file with mode: 0755]
unix102/tickets_email.sh [new file with mode: 0755]

index d3974ed..9193816 100644 (file)
@@ -63,4 +63,5 @@ $(OUTDIR)%.pem: %.pem
        cp -f $< $@
 $(OUTDIR)%.tar: %.tar
        cp -f $< $@
-
+$(OUTDIR)%.sh: %.sh
+       cp -f $< $@
index 9683f2b..aa97189 100644 (file)
@@ -1,3 +1,3 @@
-FILES = index.html cheatsheet.pdf unix101.pdf vim_exercise.tar
+FILES = index.html cheatsheet.pdf unix101.pdf vim_exercise.tar appender.sh tickets_email.sh
 RELDIR = unix102/
 include ../common.mk
diff --git a/unix102/appender.sh b/unix102/appender.sh
new file mode 100755 (executable)
index 0000000..f9ddebf
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+while [ ${#} != 0 ]; do
+   echo "${1}:"
+   cat "${1}"
+   echo ""
+   shift
+done
+
+exit 0
+
diff --git a/unix102/tickets_email.sh b/unix102/tickets_email.sh
new file mode 100755 (executable)
index 0000000..81cfe70
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash
+# Sends email when Beta tickets are available.
+
+TEST=`mktemp`
+wget -q --no-check-certificate https://ticketdriver.com/betawater/buy/tickets/ -O ${TEST}
+
+LINEMATCH=`mktemp`
+egrep '2012-04-13|Laidback|Luke' ${TEST} >> ${LINEMATCH}
+
+if [ $? = 0 ]; then
+   SUBJECT="BUY BETA TICKETS"
+   EMAIL=$1
+   EMAILBODY=`mktemp`
+   NUMBER=$2
+
+   echo "tickets_email: Tickets available!!
+https://ticketdriver.com/betawater/buy/tickets/" >> "${EMAILBODY}"
+   echo -e "\nMatching line: " >> "${EMAILBODY}"
+   cat "${LINEMATCH}" >> "${EMAILBODY}"
+   
+   mail -s "${SUBJECT}" "${EMAIL}" < "${EMAILBODY}"
+   if [ $NUMBER -n "" ]; then
+      echo "go buy tickets" | mail -s "${SUBJECT}" "${NUMBER}@msg.telus.com"
+   fi
+   rm "${EMAILBODY}"
+fi
+
+rm "${TEST}" "${LINEMATCH}"