I've been doing some grading for a course and I wanted to automate somewhat sending feedback to the students. I am able to get a CSV file with the roster information and their submissions follow a particular format (Lastname_Firstname_...). So when I'm done grading and commenting, I want to be able to blast out the comments in emails. There are about 50 students in the course so sending an email to each one would take a long time. Here is the first script:
#!/bin/bash HW_DIR=$1 SUBJECT=$2 ROSTER=CIS_111_RosterExport.csv C_DIR=$( pwd ) cd $HW_DIR for file in *; do LAST_NAME=$( echo $file | cut -d _ -f1 ) FIRST_NAME=$( echo $file | cut -d _ -f2 ) FOUND=0 while read line; do RLAST_NAME=$( echo $line | cut -d "," -f2 | tr -d \" ) RFIRST_NAME=$( echo $line | cut -d "," -f3 | tr -d \" ) if [ "$LAST_NAME" == "$RLAST_NAME" -a "$FIRST_NAME" == "$RFIRST_NAME" ]; then EMAIL=$(echo $line | cut -d , -f4 | tr -d \" ) $C_DIR/sendmail "$FIRST_NAME $LAST_NAME" $EMAIL "$SUBJECT" "Results: " $C_DIR/$HW_DIR/$file FOUND=1 fi done < $C_DIR/$ROSTER if [ $FOUND -eq 0 ]; then echo "Oh NO!" echo $file fi done
It takes as input the directory with the files I want to send and a subject line for the email. And here is my sendmail script:
#!/usr/bin/osascript on run argv set _name to (item 1 of argv) set _to to (item 2 of argv) set _subject to (item 3 of argv) set _body to (item 4 of argv) set _attachment to (item 5 of argv) tell application "Mail" set theMessage to make new outgoing message with properties {visible:true, subject:_subject, content:_body} tell theMessage make new to recipient at end of to recipients with properties {name:_name, address:_to} end tell tell content of theMessage make new attachment with properties {file name:_attachment} at after last paragraph end tell send theMessage end tell end run
"Scripts"
No comments yet. -