|
|
1.1 ! root 1: case $CONFIG in ! 2: '') . config.sh ;; ! 3: esac ! 4: echo "Extracting Pnews (with variable substitutions)" ! 5: $spitshell >Pnews <<!GROK!THIS! ! 6: $startsh ! 7: # $Header: Pnews.SH,v 4.3.1.4 86/09/05 15:21:10 lwall Exp $ ! 8: # ! 9: # $Log: Pnews.SH,v $ ! 10: # Revision 4.3.1.4 86/09/05 15:21:10 lwall ! 11: # Changes for new top-level newsgroup names. ! 12: # ! 13: # Revision 4.3.1.3 85/08/01 14:24:06 lwall ! 14: # Added AUTHORCOPY. Temp file is no longer in /tmp. 'e editor' added. ! 15: # ! 16: # Revision 4.3.1.2 85/05/17 10:36:46 lwall ! 17: # Removed some extra backslashes. ! 18: # ! 19: # Revision 4.3.1.1 85/05/10 11:30:21 lwall ! 20: # Branch for patches. ! 21: # ! 22: # Revision 4.3 85/05/01 12:20:33 lwall ! 23: # Baseline for release with 4.3bsd. ! 24: # ! 25: # ! 26: # syntax: Pnews -h headerfile or ! 27: # Pnews -h headerfile oldarticle or ! 28: # Pnews newsgroup title or just ! 29: # Pnews ! 30: ! 31: export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh \$0; kill \$\$) ! 32: ! 33: # System dependencies ! 34: ! 35: mailer="${mailer-/bin/mail}" ! 36: # if you change this to something that does signatures, take out signature code ! 37: ! 38: case $portable in ! 39: define) ! 40: # your site name ! 41: sitename=\`$hostcmd\` ! 42: # where recordings, distributions and moderators are kept ! 43: lib=\`$filexp $lib\` ! 44: # where important rn things are kept ! 45: rnlib=\`$filexp $rnlib\` ! 46: ;; ! 47: undef) ! 48: # your site name ! 49: sitename="$sitename" ! 50: # where recordings, distributions and moderators are kept ! 51: lib="$lib" ! 52: # where important rn things are kept ! 53: rnlib="$rnlib" ! 54: ;; ! 55: esac ! 56: ! 57: # your organization name ! 58: orgname="$orgname" ! 59: # what pager you use--if you have kernal paging use cat ! 60: pager="\${PAGER-$pager}" ! 61: # how you derive full names, bsd, usg, or other ! 62: nametype="$nametype" ! 63: # default editor ! 64: defeditor="$defeditor" ! 65: # how not to echo with newline ! 66: n="$n" ! 67: c="$c" ! 68: ! 69: # You should also look at the distribution warnings below marked !DIST! ! 70: # to make sure any distribution regions you are a member of are included. ! 71: # The following are some prototypical distribution groups. If you do not ! 72: # use them all set the unused ones to a non-null string such as 'none'. ! 73: loc="$locpref" ! 74: org="$orgpref" ! 75: city="$citypref" ! 76: state="$statepref" ! 77: cntry="$cntrypref" ! 78: cont="$contpref" ! 79: ! 80: test=${test-test} ! 81: sed=${sed-sed} ! 82: echo=${echo-echo} ! 83: cat=${cat-cat} ! 84: egrep=${egrep-egrep} ! 85: grep=${grep-grep} ! 86: rm=${rm-rm} ! 87: tr=${tr-tr} ! 88: inews=${inews-inews} ! 89: ! 90: !GROK!THIS! ! 91: $spitshell >>Pnews <<'!NO!SUBS!' ! 92: dotdir=${DOTDIR-${HOME-$LOGDIR}} ! 93: tmpart=$dotdir/.article ! 94: ! 95: if $test -f $dotdir/.pnewsexpert; then ! 96: expertise=expert ! 97: else ! 98: $cat <<'EOM' ! 99: I see you've never used this version of Pnews before. I will give you extra ! 100: help this first time through, but then you must remember what you learned. ! 101: If you don't understand any question, type h and a CR (carriage return) for ! 102: help. ! 103: ! 104: If you've never posted an article to the net before, it is HIGHLY recommended ! 105: that you read the netiquette document found in mod.announce.newusers so ! 106: that you'll know to avoid the commonest blunders. To do that, interrupt ! 107: Pnews, and get to the top-level prompt of rn. Say "g mod.announce.newusers" ! 108: and you are on your way. ! 109: ! 110: EOM ! 111: expertise=beginner ! 112: fi ! 113: ! 114: case $cntry in ! 115: can) stpr=Province ;; ! 116: *) stpr=State ;; ! 117: esac ! 118: ! 119: headerfile="" ! 120: case $# in ! 121: 0) ;; ! 122: *) case $1 in ! 123: -h) ! 124: headerfile="$2" ! 125: shift ! 126: shift ! 127: case $# in ! 128: 0) ! 129: oldart="" ! 130: ;; ! 131: *) ! 132: oldart="$1" ! 133: shift ! 134: ;; ! 135: esac ! 136: ;; ! 137: esac ! 138: ;; ! 139: esac ! 140: ! 141: case $headerfile in ! 142: '') ! 143: . $rnlib/Pnews.header ! 144: ;; ! 145: *) ! 146: $cat < $headerfile > $tmpart ! 147: ;; ! 148: esac ! 149: rescue="sleep 1; $cat $tmpart >>${HOME-$LOGDIR}/dead.article ; $echo Article appended to ${HOME-$LOGDIR}/dead.article ; exit" ! 150: trap "$rescue" 1 ! 151: trap "$rescue" 2 ! 152: ! 153: $echo "" ! 154: set X `$sed < $tmpart -n -e '/^Distribution: /{' -e p -e q -e '}' -e '/^$/q'` ! 155: shift ! 156: case $# in ! 157: 0|1) ! 158: set X `$sed < $tmpart -n -e '/^Newsgroups: /{' -e p -e q -e '}'` ! 159: shift ! 160: case $# in ! 161: 0|1) ! 162: set "x misc.whatever" ! 163: ;; ! 164: esac ! 165: ;; ! 166: *) ! 167: set $1 $2.whatever ! 168: ;; ! 169: esac ! 170: shift ! 171: ! 172: #: play recorded message ! 173: #if $test -s ${lib}/recording ; then ! 174: # ng=`$echo $1 | $sed "s/,.*//"` ! 175: # _rec1=${lib}/`$sed -n "/^$ng/s/^.* //p" ${lib}/recording` ! 176: # _tmp=`$echo $ng |$sed "s/\..*//"` ! 177: # _rec2=${lib}/`$cat -s ${lib}/recording|$grep ${_tmp}.all|$sed "s/^.* //"` ! 178: # if $test -f ${_rec1} ; then ! 179: # $cat -s ${_rec1} ! 180: # fi ! 181: # if $test -f ${_rec2} ; then ! 182: # $cat -s ${_rec2} ! 183: # fi ! 184: #fi ! 185: ! 186: # tell them what we think they are doing... !DIST! ! 187: case $1 in ! 188: net.*|world.*|comp.*|news.*|sci.*|rec.*|misc.*|soc.*|talk.*|mod.*) ! 189: $cat <<'EOM' ! 190: This program posts news to thousands of machines throughout the entire ! 191: civilized world. You message will cost the net hundreds if not thousands of ! 192: dollars to send everywhere. Please be sure you know what you are doing. ! 193: ! 194: EOM ! 195: ;; ! 196: $cont.*) ! 197: $echo 'This program posts news to many machines throughout the continent.' ! 198: ;; ! 199: $cntry.*) ! 200: $echo 'This program posts news to many machines throughout the country.' ! 201: ;; ! 202: $state.*) ! 203: $echo 'This program posts news to many machines throughout the state.' ! 204: ;; ! 205: $city.*) ! 206: $echo 'This program posts news to many machines throughout the city.' ! 207: ;; ! 208: $org.*) ! 209: $echo 'This program posts news to machines throughout the organization.' ! 210: ;; ! 211: $loc.*) ! 212: $echo 'This program posts news to machines throughout the local organization.' ! 213: ;; ! 214: *.*) ! 215: $echo 'This program may post news to many machines.' ! 216: ;; ! 217: *) ! 218: $echo 'This program posts news to everyone on the machine.' ! 219: ;; ! 220: esac ! 221: ans="" ! 222: while $test "$ans" = "" ; do ! 223: $echo $n "Are you absolutely sure that you want to do this? [ny] $c" ! 224: read ans ! 225: case $ans in ! 226: y*) ;; ! 227: f*) suppressmess=y ;; ! 228: h*) $cat <<'EOH' ! 229: ! 230: Type n or CR to exit, y to post. ! 231: ! 232: EOH ! 233: ans="" ;; ! 234: *) exit ;; ! 235: esac ! 236: done ! 237: ! 238: file=h ! 239: while $test "$file" = h ; do ! 240: $echo "" ! 241: $echo $n "Prepared file to include [none]: $c" ! 242: read file ! 243: case $file in ! 244: h) ! 245: $cat <<'EOH' ! 246: ! 247: If you have already produced the body of your article, type the filename ! 248: for it here. If you just want to proceed directly to the editor, type a ! 249: RETURN. In any event, you will be allowed to edit as many times as you ! 250: want before you send off the article. ! 251: EOH ! 252: ;; ! 253: '') ! 254: $echo "" >> $tmpart ! 255: state=edit ! 256: ;; ! 257: *) ! 258: $cat $file >>$tmpart ! 259: state=ask ! 260: ;; ! 261: esac ! 262: done ! 263: ! 264: $echo "" ! 265: ! 266: while true ; do ! 267: case $state in ! 268: edit) ! 269: case $expertise in ! 270: beginner) ! 271: $cat </dev/null >$dotdir/.pnewsexpert ! 272: $cat <<'EOMessage' ! 273: A temporary file has been created for you to edit. Be sure to leave at ! 274: least one blank line between the header and the body of your message. ! 275: (And until a certain bug is fixed all over the net, don't start the body of ! 276: your message with any indentation, or it may get eaten.) ! 277: ! 278: Within the header may be fields that you don't understand. If you don't ! 279: understand a field (or even if you do), you can simply leave it blank, and ! 280: it will go away when the article is posted. ! 281: ! 282: Type return to get the default editor, or type the name of your favorite ! 283: editor. ! 284: ! 285: EOMessage ! 286: ;; ! 287: esac ! 288: case "${VISUAL-${EDITOR-}}" in ! 289: '') ! 290: tmp=h ! 291: ;; ! 292: *) ! 293: tmp='' ! 294: ;; ! 295: esac ! 296: while $test "$tmp" = h ; do ! 297: $echo $n "Editor [${VISUAL-${EDITOR-$defeditor}}]: $c" ! 298: read tmp ! 299: case $tmp in ! 300: h) ! 301: $cat <<'EOH' ! 302: ! 303: Type a return to get the default editor, or type the name of the editor you ! 304: prefer. The default editor depends on the VISUAL and EDITOR environment ! 305: variables. ! 306: ! 307: EOH ! 308: ;; ! 309: '') ! 310: ;; ! 311: *) ! 312: VISUAL=$tmp ! 313: export VISUAL ! 314: ;; ! 315: esac ! 316: done ! 317: trap : 2 ! 318: ${VISUAL-${EDITOR-$defeditor}} $tmpart $oldart ! 319: trap "$rescue" 2 ! 320: state=ask ! 321: ;; ! 322: ! 323: ask) ! 324: $echo "" ! 325: $echo $n "Send, abort, edit, or list? $c" ! 326: read ans ! 327: ! 328: case "$ans" in ! 329: a*) ! 330: state=rescue ! 331: ;; ! 332: e*) ! 333: set $ans ! 334: case $# in ! 335: 2) VISUAL="$2" ;; ! 336: esac ! 337: state=edit ! 338: ;; ! 339: l*) ! 340: $pager $tmpart ! 341: state=ask ! 342: ;; ! 343: s*) ! 344: state=send ! 345: ;; ! 346: h*) ! 347: $cat <<'EOH' ! 348: ! 349: Type s to send the article, a to abort and append the article to dead.article, ! 350: e to edit the article again, or l to list the article. ! 351: ! 352: To invoke an alternate editor, type 'e editor'. ! 353: EOH ! 354: esac ! 355: ;; ! 356: ! 357: send) ! 358: set X `$sed < $tmpart -n -e '/^Newsgroups: /{' -e p -e q -e '}'` ! 359: shift ! 360: case $# in ! 361: 2) ! 362: state=cleanup ! 363: if $test -f $lib/moderators; then ! 364: tryinews=no ! 365: shift ! 366: case "$1" in ! 367: *,*) set `$echo $1 | tr ',' ' '`;; ! 368: esac ! 369: for newsgroup in $*; do ! 370: # the following screwy sed should prevent Eunice from hanging on no match ! 371: moderator=`$sed <$lib/moderators \ ! 372: -e "/^$newsgroup[ ]/!s/.*//" \ ! 373: -e "s/^$newsgroup[ ]//"` ! 374: case ${moderator}X in ! 375: X) tryinews=yes ! 376: ;; ! 377: *) ! 378: $echo Mailing to moderator $moderator ! 379: case "$sign" in ! 380: n*) ;; ! 381: *) ! 382: if $test -f $dotdir/.signature; then ! 383: echo $n "Append .signature file? [y] $c" ! 384: read ans ! 385: case $ans in ! 386: ''|y*) ! 387: echo "-- " >> $tmpart ! 388: cat $dotdir/.signature >> $tmpart ! 389: ;; ! 390: esac ! 391: fi ! 392: sign=no ! 393: ;; ! 394: esac ! 395: case "$mailer" in ! 396: *recmail) ! 397: $echo To: $moderator | $cat - $tmpart | $mailer ! 398: ;; ! 399: *) ! 400: $mailer $moderator < $tmpart ! 401: ;; ! 402: esac ! 403: case $? in ! 404: 0) ;; ! 405: *) ! 406: $echo Unable to mail to moderator $moderator ! 407: state=rescue ! 408: ;; ! 409: esac ! 410: ;; ! 411: esac ! 412: done ! 413: else ! 414: tryinews=yes ! 415: fi ! 416: case "$tryinews" in ! 417: yes) ! 418: if $inews -h < $tmpart ; then ! 419: : null ! 420: else ! 421: state=rescue ! 422: fi ! 423: ;; ! 424: esac ! 425: ;; ! 426: *) ! 427: $echo "" ! 428: $echo "Malformed Newsgroups line." ! 429: $echo "" ! 430: sleep 1 ! 431: state=edit ! 432: ;; ! 433: esac ! 434: ;; ! 435: rescue) ! 436: $cat $tmpart >> ${HOME-$LOGDIR}/dead.article ! 437: $echo "Article appended to ${HOME-$LOGDIR}/dead.article" ! 438: $echo "A copy may be temporarily found in $tmpart" ! 439: exit ! 440: ;; ! 441: cleanup) ! 442: case "${AUTHORCOPY-none}" in ! 443: none) ! 444: ;; ! 445: *) if $echo From $USER `date` >> $AUTHORCOPY; then ! 446: $cat $tmpart >> $AUTHORCOPY ! 447: $echo "Article appended to $AUTHORCOPY" ! 448: $echo "" >> $AUTHORCOPY ! 449: $echo "" >> $AUTHORCOPY ! 450: else ! 451: $echo "Cannot append to $AUTHORCOPY" ! 452: fi ! 453: ;; ! 454: esac ! 455: exit ! 456: ;; ! 457: esac ! 458: done ! 459: !NO!SUBS! ! 460: $eunicefix Pnews ! 461: chmod 755 Pnews ! 462: $spitshell >Pnews.header <<'!NO!SUBS!' ! 463: case $# in ! 464: 0) ! 465: ng=h ! 466: while $test "$ng" = h ; do ! 467: $echo "" ! 468: $echo $n "Newsgroup(s): $c" ! 469: read ng ! 470: case $ng in ! 471: h) ! 472: $cat <<'EOH' ! 473: ! 474: Type the name of one or more newsgroups to which you wish to post an article. ! 475: If you want to post to multiple newsgroups, it is better to do them all at ! 476: once than to post to each newsgroup individually, which defeats the news ! 477: reading programs' strategies of eliminating duplicates. ! 478: ! 479: Separate multiple newsgroup names with commas. ! 480: EOH ! 481: ;; ! 482: esac ! 483: done ! 484: ;; ! 485: *) ! 486: ng=$1 ! 487: shift ! 488: ;; ! 489: esac ! 490: case $ng in ! 491: *\ *) ! 492: ng=`$echo "$ng" | $sed 's/[, ] */,/g'` ! 493: ;; ! 494: esac ! 495: case $ng in ! 496: net.*|mod.*|comp.*|news.*|sci.*|rec.*|misc.*|soc.*|talk.*) ! 497: defdist=world ! 498: dist=h ! 499: ;; ! 500: *.*) ! 501: defdist=`expr "X$ng" : 'X\([a-z0-9]*\)'` ! 502: dist=h ! 503: ;; ! 504: *) ! 505: defdist='' ! 506: dist='' ! 507: ;; ! 508: esac ! 509: ! 510: while $test "$dist" = h ; do ! 511: if $test -f $lib/distributions; then ! 512: $echo " " ! 513: $echo "Your local distribution prefixes are:" ! 514: $cat $lib/distributions ! 515: $echo " " ! 516: else ! 517: $egrep -v '[ ]none$' <<EOM ! 518: ! 519: Your local distribution prefixes are: ! 520: Local organization: $loc ! 521: Organization: $org ! 522: City: $city ! 523: $stpr: $state ! 524: Country: $cntry ! 525: Continent: $cont ! 526: Everywhere: world ! 527: ! 528: EOM ! 529: fi ! 530: $echo $n "Distribution ($defdist): $c" ! 531: read dist ! 532: case $dist in ! 533: '') dist=$defdist ;; ! 534: esac ! 535: case $dist in ! 536: h) ! 537: $cat <<'EOH' ! 538: ! 539: The Distribution line may be used to limit the distribution of an article ! 540: to some subset of the systems that would receive the article based only on ! 541: the Newsgroups line. For example, if you want to sell your car in talk.auto, ! 542: and you live in New Jersey, you might want to put "nj" on the Distribution ! 543: line to avoid advertising in California, which has enough problems of its own. ! 544: The actual area designators to use depend on where you are, of course. ! 545: EOH ! 546: ;; ! 547: ''|$loc*|$org*|$city*|$state*|$cntry*|$cont*|$defdist) ! 548: ;; ! 549: net*|world*|comp*|news*|sci*|rec*|misc*|soc*|talk*) ! 550: dist='' ! 551: ;; ! 552: *) ! 553: if $test -f $lib/distributions && \ ! 554: $egrep "^$dist[ ]" $lib/distributions >$tmpart && \ ! 555: $test -s $tmpart; then ! 556: : null ! 557: else ! 558: $echo "Unrecognized distribution prefix--type h for help, CR to use anyway." ! 559: defdist=$dist ! 560: dist=h ! 561: fi ! 562: ;; ! 563: esac ! 564: done ! 565: ! 566: case $ng in ! 567: *net.general*) ! 568: follow=`echo "$ng" | sed 's/net\.general/net.followup/g'` ! 569: ;; ! 570: *) ! 571: follow="" ! 572: ;; ! 573: esac ! 574: ! 575: case $# in ! 576: 0) ! 577: title=h ! 578: while $test "$title" = h ; do ! 579: $echo "" ! 580: $echo $n "Title/Subject: $c" ! 581: read title ! 582: case $title in ! 583: h) ! 584: $cat <<'EOH' ! 585: ! 586: Type the title for your article. Please make it as informative as possible ! 587: (within reason) so that people who aren't interested won't have to read the ! 588: article to find out they aren't interested. This includes marking movie ! 589: spoilers as (spoiler), and rotated jokes as (rot 13). ! 590: EOH ! 591: ;; ! 592: esac ! 593: done ! 594: ;; ! 595: *) ! 596: title="$*" ! 597: ;; ! 598: esac ! 599: ! 600: # now build a file with a header for them to edit ! 601: ! 602: set X ${USER-${LOGNAME-`who am i`}} ! 603: shift ! 604: logname=$1 ! 605: case $logname in ! 606: *!*) logname=`expr "$logname" : '!\(.*\)$'` ;; ! 607: esac ! 608: case ${NAME-$nametype} in ! 609: bsd) ! 610: fullname=`$sed </etc/passwd -e "/^$logname:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:\([^,:;]*\).*"'$'"/\1/" -e "q" -e "}" -e "d"` ! 611: case $fullname in ! 612: *'&'*) : GACK ! 613: lname=`$echo $logname | $tr 'a-z' 'A-Z'` ! 614: lname=`$echo $lname $logname | $sed 's/^\(.\)[^ ]* ./\1/'` ! 615: fullname=`$echo "$fullname" | $sed "s/&/${lname}/"` ! 616: ;; ! 617: esac ! 618: ;; ! 619: usg) ! 620: fullname=`$sed </etc/passwd -e "/^$logname:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:\([^(:]*\).*"'$'"/\1/" -e "s/^.*-//" -e "q" -e "}" -e "d"` ! 621: ;; ! 622: *) ! 623: fullname=${NAME-`$cat $dotdir/.fullname`} ! 624: ;; ! 625: esac ! 626: ! 627: orgname=${ORGANIZATION-$orgname} ! 628: case $orgname in ! 629: /*) orgname=`$cat $orgname` ;; ! 630: esac ! 631: ! 632: $cat > $tmpart <<EOHeader ! 633: Newsgroups: $ng ! 634: Subject: $title ! 635: Expires: ! 636: References: ! 637: Sender: ! 638: Reply-To: $logname@$sitename.UUCP ($fullname) ! 639: Followup-To: $follow ! 640: Distribution: $dist ! 641: Organization: $orgname ! 642: Keywords: ! 643: ! 644: EOHeader ! 645: ! 646: !NO!SUBS! ! 647: $eunicefix Pnews.header
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.