-
Notifications
You must be signed in to change notification settings - Fork 3
/
iii
executable file
·158 lines (129 loc) · 4.15 KB
/
iii
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#! /bin/csh
# (c) [email protected]
# intro script 2011-2012-2013
#
# revision history
# builtin vars
setenv dfile nfile.asc # datafile
setenv wrap 65 # wordwrap length
setenv fail 0
# make things that need to exist:
foreach auxdir ( trash bios )
if( ! -e $auxdir ) then
echo "hey! you look new here. imma make you a directory: " $auxdir
mkdir $auxdir
endif
end
# move auxfiles to trash
foreach auxfile (orly spells edits)
if ( -e $auxfile ) then
mv $auxfile trash/{$auxfile}_`date +%yy%mm%dd_%Hh%Mm%Ss`
endif
touch $auxfile
chmod +x $auxfile
end
# if nonames, mknames
if( ! -e $dfile ) then
echo "nonames! creating $dfile"
cat >! $dfile << EOF
first;last;email
bob;smith;[email protected]
jim;smith@work;[email protected]
EOF
endif
# o1 vars
# # NB: "head 1" prevents errors if you've defined someone twice :/
setenv str1 `grep -i ';'$1';' $dfile|head -1 | tr '[A-Z]' '[a-z]'`
setenv str2 `grep -i ';'$2';' $dfile|head -1 | tr '[A-Z]' '[a-z]'`
setenv str3 `grep -i ';'$3';' $dfile|head -1 | tr '[A-Z]' '[a-z]'`
setenv f1 `echo $str1 | awk -F\; '{print $1}'`
setenv f2 `echo $str2 | awk -F\; '{print $1}'`
setenv f3 `echo $str3 | awk -F\; '{print $1}'`
setenv l1 `echo $str1 | awk -F\; '{print $2}'`
setenv l2 `echo $str2 | awk -F\; '{print $2}'`
setenv l3 `echo $str3 | awk -F\; '{print $2}'`
setenv e1 `echo $str1 | awk -F\; '{print $3}'`
setenv e2 `echo $str2 | awk -F\; '{print $3}'`
setenv e3 `echo $str3 | awk -F\; '{print $3}'`
# if 1st name there in nfile.asc?
if( $str1 == '') then
setenv fail 1
echo $1 not found
echo "./web http://mail.google.com/mail/u/0/#search/from%3a"$1 >> orly
endif
# if 2nd name there in nfile.asc?
if( $str2 == '') then
setenv fail 1
echo $2 not found
echo "./web http://mail.google.com/mail/u/0/#search/from%3a"$2 >> orly
endif
# if 3rd name there in nfile.asc?
if( $str3 == '') then
setenv fail 1
echo $3 not found
echo "./web http://mail.google.com/mail/u/0/#search/from%3a"$3 >> orly
endif
# if either is missing, you need to edit nfile.asc.
if ( $fail == 1 ) then
echo "vi + $dfile" >> orly
endif
# o2 vars (fns of o1 vars)
setenv eml ${l1}_{$l2}_{$l3}.eml
setenv n1 `echo $l1|cut -d@ -f1`
setenv n2 `echo $l2|cut -d@ -f1`
setenv n3 `echo $l3|cut -d@ -f1`
if ( $fail == 0 ) then
# BEGIN MAIN
#invariate headers
cat >! $eml << EOF
User-Agent: SNDMSG
Time: `date` (NYC)
EOF
# recipients
echo "To: $f1 $n1 <$e1>, $f2 $n2 <$e2> , $f3 $n3 <$e3> " >> $eml
#subject
echo "Subject: intro: "$f1" "$n1" <-> "$f2" "$n2 ", "$f3" "$n3 >> $eml
# NB: done with $n1 $n2 $n3
#body
echo "+@"$f2" and @"$f3":++please meet "$f1".+" | tr '+' '\n' >> $eml
if ( -e bios/{$l1}.txt ) then
grep -v '^[ ]*%' < bios/${l1}.txt | tr '\n' ' ' | sed -e 's/ [ ]*/ /g' -e 's/^[ ]*//' | tr '+' '\n' | fold -s -b -w $wrap >> $eml
echo "" >> $eml
else
echo "missing bio for $l1 -- please execute:";echo "$EDITOR bios/$l1.txt"
echo "$EDITOR bios/$l1.txt" >> orly
setenv fail 1
endif
echo "+@"$f1":++please meet "$f2" and "$f3".+" | tr '+' '\n' >> $eml
if ( -e bios/{$l2}.txt ) then
grep -v '^[ ]*%' < bios/${l2}.txt | tr '\n' ' ' | sed -e 's/ [ ]*/ /g' -e 's/^[ ]*//' | tr '+' '\n' | fold -s -b -w $wrap >> $eml
echo "" >> $eml
echo "" >> $eml
else
echo "missing bio for $l2 -- please execute:";echo "$EDITOR bios/$l2.txt"
echo "$EDITOR bios/$l2.txt" >> orly
setenv fail 1
endif
if ( -e bios/{$l3}.txt ) then
grep -v '^[ ]*%' < bios/${l3}.txt | tr '\n' ' ' | sed -e 's/ [ ]*/ /g' -e 's/^[ ]*//' | tr '+' '\n' | fold -s -b -w $wrap >> $eml
echo "" >> $eml
else
echo "missing bio for $l3 -- please execute:";echo "$EDITOR bios/$l3.txt"
echo "$EDITOR bios/$l3.txt" >> orly
setenv fail 1
endif
#outtro
echo "+i hope you all find time to connect.++best,++chris"| tr '+' '\n' >> $eml
endif
if ( $fail == 0 ) then
more $eml
touch spells
chmod +x spells
echo "aspell -c bios/$l3.txt;aspell -c bios/$l2.txt;aspell -c bios/$l1.txt" >> spells
touch edits
chmod +x edits
echo "$EDITOR bios/$l3.txt; $EDITOR bios/$l2.txt; $EDITOR bios/$l1.txt;" >> edits
endif
if ( $fail == 1 ) then
rm -f $eml
endif