Added some sample bash scripts to the UNIX102 page.

This commit is contained in:
Elana Hashman 2012-03-08 16:10:04 -05:00
parent aee5c22f92
commit e09355b57c
4 changed files with 42 additions and 2 deletions

View File

@ -63,4 +63,5 @@ $(OUTDIR)%.pem: %.pem
cp -f $< $@ cp -f $< $@
$(OUTDIR)%.tar: %.tar $(OUTDIR)%.tar: %.tar
cp -f $< $@ cp -f $< $@
$(OUTDIR)%.sh: %.sh
cp -f $< $@

View 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/ RELDIR = unix102/
include ../common.mk include ../common.mk

11
unix102/appender.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
while [ ${#} != 0 ]; do
echo "${1}:"
cat "${1}"
echo ""
shift
done
exit 0

28
unix102/tickets_email.sh Executable file
View File

@ -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}"