|
|
1.1 root 1: #!/bin/sh
2: # : Pnews.SH,v 4.3.1.2 85/05/17 10:36:46 lwall Exp $
3: #
4: # : Pnews.SH,v $
5: # Revision 4.3.1.2 85/05/17 10:36:46 lwall
6: # Removed some extra backslashes.
7: #
8: # Revision 4.3.1.1 85/05/10 11:30:21 lwall
9: # Branch for patches.
10: #
11: # Revision 4.3 85/05/01 12:20:33 lwall
12: # Baseline for release with 4.3bsd.
13: #
14: #
15: # syntax: Pnews -h headerfile or
16: # Pnews -h headerfile oldarticle or
17: # Pnews newsgroup title or just
18: # Pnews
19:
20: export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0; kill $$)
21:
22: # System dependencies
23:
24: mailer="/usr/lib/sendmail"
25: # if you change this to something that does signatures, take out signature code
26:
27: case define in
28: define)
29: # your site name
30: sitename=`hostname`
31: # where recordings, distributions and moderators are kept
32: lib=`/usr/local/lib/rn/filexp /usr/spool/news/lib`
33: # where important rn things are kept
34: rnlib=`/usr/local/lib/rn/filexp /usr/local/lib/rn`
35: ;;
36: undef)
37: # your site name
38: sitename="ucbvax"
39: # where recordings, distributions and moderators are kept
40: lib="/usr/spool/news/lib"
41: # where important rn things are kept
42: rnlib="/usr/local/lib/rn"
43: ;;
44: esac
45:
46: # your organization name
47: orgname="University of California, Berkeley"
48: # what pager you use--if you have kernal paging use cat
49: pager="${PAGER-/usr/ucb/more}"
50: # how you derive full names, bsd, usg, or other
51: nametype="bsd"
52: # default editor
53: defeditor="/usr/ucb/vi"
54: # how not to echo with newline
55: n="-n"
56: c=""
57:
58: # You should also look at the distribution warnings below marked !DIST!
59: # to make sure any distribution regions you are a member of are included.
60: # The following are some prototypical distribution groups. If you do not
61: # use them all set the unused ones to a non-null string such as 'none'.
62: loc="local"
63: org="ucb"
64: city="ba"
65: state="ca"
66: cntry="usa"
67: cont="na"
68:
69: test=/bin/test
70: sed=sed
71: echo=echo
72: cat=cat
73: egrep=/usr/bin/egrep
74: grep=grep
75: rm=rm
76: tr=tr
77: inews=/usr/spool/news/lib/inews
78:
79: if $test -f ${DOTDIR-${HOME-$LOGDIR}}/.pnewsexpert; then
80: expertise=expert
81: else
82: $cat <<'EOM'
83: I see you've never used this version of Pnews before. I will give you extra
84: help this first time through, but then you must remember what you learned.
85: If you don't understand any question, type h and a CR (carriage return) for
86: help.
87:
88: If you've never posted an article to the net before, it is HIGHLY recommended
89: that you read the netiquette document found in net.announce.newusers so
90: that you'll know to avoid the commonest blunders. To do that, interrupt
91: Pnews, and get to the top-level prompt of rn. Say "g net.announce.newusers"
92: and you are on your way.
93:
94: EOM
95: expertise=beginner
96: fi
97:
98: case $cntry in
99: can) stpr=Province ;;
100: *) stpr=State ;;
101: esac
102:
103: tmpart=/tmp/article$$
104:
105: headerfile=""
106: case $# in
107: 0) ;;
108: *) case $1 in
109: -h)
110: headerfile="$2"
111: shift
112: shift
113: case $# in
114: 0)
115: oldart=""
116: ;;
117: *)
118: oldart="$1"
119: shift
120: ;;
121: esac
122: ;;
123: esac
124: ;;
125: esac
126:
127: case $headerfile in
128: '')
129: . $rnlib/Pnews.header
130: ;;
131: *)
132: $cat < $headerfile > $tmpart
133: ;;
134: esac
135: rescue="sleep 1; $cat $tmpart >>${HOME-$LOGDIR}/dead.article ; $echo saved in ${HOME-$LOGDIR}/dead.article ; $rm -f $tmpart; exit"
136: trap "$rescue" 1
137: trap "$rescue" 2
138:
139: $echo ""
140: set X `$sed < $tmpart -n -e '/^Distribution: /{' -e p -e q -e '}' -e '/^$/q'`
141: shift
142: case $# in
143: 0|1)
144: set X `$sed < $tmpart -n -e '/^Newsgroups: /{' -e p -e q -e '}'`
145: shift
146: case $# in
147: 0|1)
148: set "x net.whatever"
149: ;;
150: esac
151: ;;
152: *)
153: set $1 $2.whatever
154: ;;
155: esac
156: shift
157:
158: #: play recorded message
159: #if $test -s ${lib}/recording ; then
160: # ng=`$echo $1 | $sed "s/,.*//"`
161: # _rec1=${lib}/`$sed -n "/^$ng/s/^.* //p" ${lib}/recording`
162: # _tmp=`$echo $ng |$sed "s/\..*//"`
163: # _rec2=${lib}/`$cat -s ${lib}/recording|$grep ${_tmp}.all|$sed "s/^.* //"`
164: # if $test -f ${_rec1} ; then
165: # $cat -s ${_rec1}
166: # fi
167: # if $test -f ${_rec2} ; then
168: # $cat -s ${_rec2}
169: # fi
170: #fi
171:
172: # tell them what we think they are doing... !DIST!
173: case $1 in
174: net.*)
175: $echo 'This program posts news to many hundreds of machines throughout the world.'
176: ;;
177: $cont.*)
178: $echo 'This program posts news to many machines throughout the continent.'
179: ;;
180: $cntry.*)
181: $echo 'This program posts news to many machines throughout the country.'
182: ;;
183: $state.*)
184: $echo 'This program posts news to many machines throughout the state.'
185: ;;
186: $city.*)
187: $echo 'This program posts news to many machines throughout the city.'
188: ;;
189: $org.*)
190: $echo 'This program posts news to machines throughout the organization.'
191: ;;
192: $loc.*)
193: $echo 'This program posts news to machines throughout the local organization.'
194: ;;
195: *.*)
196: $echo 'This program may post news to many machines.'
197: ;;
198: *)
199: $echo 'This program posts news to everyone on the machine.'
200: ;;
201: esac
202: ans=""
203: while $test "$ans" = "" ; do
204: $echo $n "Are you absolutely sure that you want to do this? [ny] $c"
205: read ans
206: case $ans in
207: y*) ;;
208: f*) suppressmess=y ;;
209: h*) $cat <<'EOH'
210:
211: Type n or CR to exit, y to post.
212:
213: EOH
214: ans="" ;;
215: *) exit ;;
216: esac
217: done
218:
219: file=h
220: while $test "$file" = h ; do
221: $echo ""
222: $echo $n "Prepared file to include [none]: $c"
223: read file
224: case $file in
225: h)
226: $cat <<'EOH'
227:
228: If you have already produced the body of your article, type the filename
229: for it here. If you just want to proceed directly to the editor, type a
230: RETURN. In any event, you will be allowed to edit as many times as you
231: want before you send off the article.
232: EOH
233: ;;
234: '')
235: $echo "" >> $tmpart
236: state=edit
237: ;;
238: *)
239: $cat $file >>$tmpart
240: state=ask
241: ;;
242: esac
243: done
244:
245: $echo ""
246:
247: while true ; do
248: case $state in
249: edit)
250: case $expertise in
251: beginner)
252: $cat </dev/null >${DOTDIR-${HOME-$LOGDIR}}/.pnewsexpert
253: $cat <<'EOMessage'
254: A temporary file has been created for you to edit. Be sure to leave at
255: least one blank line between the header and the body of your message.
256: (And until a certain bug is fixed all over the net, don't start the body of
257: your message with any indentation, or it may get eaten.)
258:
259: Within the header may be fields that you don't understand. If you don't
260: understand a field (or even if you do), you can simply leave it blank, and
261: it will go away when the article is posted.
262:
263: Type return to get the default editor, or type the name of your favorite
264: editor.
265:
266: EOMessage
267: ;;
268: esac
269: case "${VISUAL-${EDITOR-}}" in
270: '')
271: tmp=h
272: ;;
273: *)
274: tmp=''
275: ;;
276: esac
277: while $test "$tmp" = h ; do
278: $echo $n "Editor [${VISUAL-${EDITOR-$defeditor}}]: $c"
279: read tmp
280: case $tmp in
281: h)
282: $cat <<'EOH'
283:
284: Type a return to get the default editor, or type the name of the editor you
285: prefer. The default editor depends on the VISUAL and EDITOR environment
286: variables.
287:
288: EOH
289: ;;
290: '')
291: ;;
292: *)
293: VISUAL=$tmp
294: export VISUAL
295: ;;
296: esac
297: done
298: trap : 2
299: ${VISUAL-${EDITOR-$defeditor}} $tmpart $oldart
300: trap "$rescue" 2
301: state=ask
302: ;;
303:
304: ask)
305: $echo ""
306: $echo $n "Send, abort, edit, or list? $c"
307: read ans
308:
309: case $ans in
310: a*)
311: state=rescue
312: ;;
313: e*)
314: state=edit
315: ;;
316: l*)
317: $pager $tmpart
318: state=ask
319: ;;
320: s*)
321: state=send
322: ;;
323: h*)
324: $cat <<'EOH'
325:
326: Type s to send the article, a to abort and append the article to dead.article,
327: e to edit the article again, or l to list the article.
328: EOH
329: esac
330: ;;
331:
332: send)
333: set X `$sed < $tmpart -n -e '/^Newsgroups: /{' -e p -e q -e '}'`
334: shift
335: case $# in
336: 2)
337: state=cleanup
338: if $test -f $lib/moderators; then
339: tryinews=no
340: shift
341: case "$1" in
342: *,*) set `$echo $1 | tr ',' ' '`;;
343: esac
344: for newsgroup in $*; do
345: # the following screwy sed should prevent Eunice from hanging on no match
346: moderator=`$sed <$lib/moderators \
347: -e "/^$newsgroup[ ]/!s/.*//" \
348: -e "s/^$newsgroup[ ]//"`
349: case ${moderator}X in
350: X) tryinews=yes
351: ;;
352: *)
353: $echo Mailing to moderator $moderator
354: case "$mailer" in
355: *recmail)
356: $echo To: $moderator | $cat - $tmpart | $mailer
357: ;;
358: *)
359: $mailer $moderator < $tmpart
360: ;;
361: esac
362: case $? in
363: 0) ;;
364: *)
365: $echo Unable to mail to moderator $moderator
366: state=rescue
367: ;;
368: esac
369: ;;
370: esac
371: done
372: else
373: tryinews=yes
374: fi
375: case "$tryinews" in
376: yes)
377: if $inews -h < $tmpart ; then
378: : null
379: else
380: state=rescue
381: fi
382: ;;
383: esac
384: ;;
385: *)
386: $echo ""
387: $echo "Malformed Newsgroups line."
388: $echo ""
389: sleep 1
390: state=edit
391: ;;
392: esac
393: ;;
394: rescue)
395: $cat $tmpart >> ${HOME-$LOGDIR}/dead.article
396: $echo "Article saved to ${HOME-$LOGDIR}/dead.article"
397: state=cleanup
398: ;;
399: cleanup)
400: $rm -f $tmpart
401: exit
402: ;;
403: esac
404: done
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.