-
Notifications
You must be signed in to change notification settings - Fork 3
/
ii
157 lines (127 loc) · 3.66 KB
/
ii
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
#! /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
setenv verbose 0 # if verbose, print the email
# 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: "tail 1" prevents errors if you've defined someone twice :/
setenv str1 `grep -i ';'$1';' $dfile|tail -1 | tr '[A-Z]' '[a-z]'`
setenv str2 `grep -i ';'$2';' $dfile|tail -1 | tr '[A-Z]' '[a-z]'`
setenv f1 `echo $str1 | awk -F\; '{print $1}'`
setenv f2 `echo $str2 | awk -F\; '{print $1}'`
setenv l1 `echo $str1 | awk -F\; '{print $2}'`
setenv l2 `echo $str2 | awk -F\; '{print $2}'`
setenv e1 `echo $str1 | awk -F\; '{print $3}'`
setenv e2 `echo $str2 | awk -F\; '{print $3}'`
# if 1st name there in nfile.asc?
if( $l1 == '') 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?
# used to be $str but failed on spaces
if( $l2 == '') then
setenv fail 1
echo $2 not found
echo "./web http://mail.google.com/mail/u/0/#search/from%3a"$2 >> 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}.eml
setenv n1 `echo $l1|cut -d@ -f1|sed -e 's/_/ /g'`
setenv n2 `echo $l2|cut -d@ -f1|sed -e 's/_/ /g'`
if ( $fail == 0 ) then
# BEGIN MAIN
#invariate headers
cat >! $eml << EOF
User-Agent: SNDMSG-orly
Time: `date` (NYC)
EOF
# recipients
echo "To: $f1 $n1 <$e1>, $f2 $n2 <$e2> " >> $eml
#subject
echo "Subject: intro: "$f1" "$n1" <-> "$f2" "$n2 >> $eml
# NB: done with $n1 $n2
#body
echo "+@"$f2":++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".+" | 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
else
echo "missing bio for $l2 -- please execute:";echo "$EDITOR bios/$l2.txt"
echo "$EDITOR bios/$l2.txt" >> orly
setenv fail 1
endif
#outtro
echo "+i hope you can both find time to connect.++best,++chris"| tr '+' '\n' >> $eml
endif
if ( $fail == 0 ) then
if ( $verbose == 1 ) then
more $eml
endif
# if all worked, orly views product
echo view $eml >> orly
touch spells
chmod +x spells
echo "aspell -c bios/$l2.txt;aspell -c bios/$l1.txt" >> spells
touch edits
chmod +x edits
echo "$EDITOR bios/$l1.txt; $EDITOR bios/$l2.txt" >> edits
endif
if ( $fail == 1 ) then
rm -f $eml
endif
# make a file to source to reset all variables
cat >! /tmp/orly-vars.sh << EOF
setenv dfile $dfile
setenv e1 $e1
setenv e2 $e2
setenv EDITOR $EDITOR
setenv eml $eml
setenv f1 $f1
setenv f2 $f2
setenv fail $fail
setenv l1 $l1
setenv l2 $l2
setenv n1 $n1
setenv n2 $n2
setenv verbose $verbose
setenv wrap $wrap
EOF
#setenv str1 $str1
#setenv str2 $str2