home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume6 / maildigest < prev    next >
Text File  |  1986-11-30  |  23KB  |  865 lines

  1. Submitted: taylor@hplabs
  2. Mod.sources: Volume 6, Issue 6
  3. Archive-name: maildigest
  4.  
  5. [ The mail.digest.m program refers to mailx; change this to Mail
  6.   if you have it.  If you have neither, you'll have to do something
  7.   else to get the subject lines in there.  Change the "SEE ALSO"
  8.   in digest.1 also, which has to be the chattiest manpage in Unix(tm)
  9.   history.  --r$]
  10.  
  11. --------------------------------cut here--------------------
  12. # This is a shell archive.  Remove anything before this line,
  13. # then unpack it by saving it in a file and typing "sh file".
  14. # Contents:  Makefile center.1 center.c digest.1 digest.all digest.awk
  15. #    issue.master mail.digest.m mail.issue.m mydate.1 mydate.c readword.c
  16.  
  17. echo x - Makefile
  18. sed 's/^XX//' > "Makefile" <<'@//E*O*F Makefile//'
  19. XX# Makefile for the Digest system...
  20. XX#
  21. XX# This entire Digest system is;
  22. XX#   (C) Copyright 1986, Dave Taylor, Hewlett-Packard
  23. XX#
  24.  
  25. XX# To use, merely type "make all"
  26.  
  27. XXSHELL=/bin/csh
  28.  
  29. XXCFILES= readword.c center.c mydate.c
  30. XXSCRIPTS= digest.all digest.awk digest.tail issue mail.digest mail_issue \
  31. XX    volume_number
  32.  
  33. XXCC=/bin/cc
  34. XXCFLAGS=-O
  35.  
  36. XXall:    readword .DIGESTNAME .DIGESTADDR .MODERATOR .MOD_ADDR \
  37. XX    center mydate ${SCRIPTS}
  38. XX    @chmod a+rx digest.all issue mail.digest mail_issue
  39. XX    @echo digest system ready to go...
  40.  
  41. XXreadword : readword.c
  42. XX    @echo Creating readword program for interactive section of Makefile
  43. XX    @echo " "
  44. XX    ${CC} ${CFLAGS} readword.c -o readword
  45.  
  46. XXcenter : center.c
  47. XX    ${CC} ${CFLAGS} center.c -o center
  48. XX    
  49. XXmydate: mydate.c
  50. XX    ${CC} ${CFLAGS} mydate.c -o mydate
  51.  
  52. XX.DIGESTNAME: 
  53. XX    @echo " "
  54. XX    @echo -n "Please enter the name of the digest: "
  55. XX    @readword .DIGESTNAME
  56.  
  57. XX.DIGESTADDR:
  58. XX    @echo -n "Please enter the alias you'll use for sending the digest: "
  59. XX    @readword .DIGESTADDR
  60.  
  61. XX.MODERATOR: 
  62. XX    @echo -n "Please enter the full name of the moderator: "
  63. XX    @readword .MODERATOR
  64.  
  65. XX.MOD_ADDR:
  66. XX    @echo -n "Please enter the mailing address for mail to the moderator: "
  67. XX    @readword .MOD_ADDR
  68. XX    @echo " "
  69.  
  70. XXdigest.tail: 
  71. XX    @echo 'Creating digest.tail...'
  72. XX    @echo " " > digest.tail
  73. XX    @echo "-------------------------------------" >> digest.tail
  74. XX    @echo " " >> digest.tail
  75. XX    @echo \
  76. XX        "To join this group or have your thoughts in the next issue, please" \
  77. XX    >> digest.tail
  78. XX    @echo \
  79. XX    "send electronic mail to `cat .MODERATOR` at the following address;" \
  80. XX    >> digest.tail
  81. XX    @echo " " >> digest.tail
  82. XX    @echo "        `cat .MOD_ADDR`" >> digest.tail
  83. XX    @echo " " >> digest.tail
  84. XX    @echo "The views expressed in `cat .DIGESTNAME`" >> digest.tail
  85. XX    @echo "are those of the individual authors only.">> digest.tail
  86. XX    @echo " " >> digest.tail
  87. XX    @echo "*********************" >> digest.tail
  88. XX    @echo "End of `cat .DIGESTNAME`" >> digest.tail
  89. XX    @echo "*********************" >> digest.tail
  90.  
  91. XXissue: issue.master 
  92. XX    @echo "Creating issue script..."
  93. XX    @echo " " > issue
  94. XX    @echo " digest_name='`cat .DIGESTNAME`'" >> issue
  95. XX    @cat issue.master >> issue
  96.  
  97. XXmail.digest: mail.digest.m 
  98. XX    @echo "Creating mail.digest..."
  99. XX    @echo " " > mail.digest
  100. XX    @echo " digest_name='`cat .DIGESTNAME`'" >> mail.digest
  101. XX    @cat mail.digest.m >> mail.digest
  102.  
  103. XXmail_issue: mail.issue.m 
  104. XX    @echo "Creating mail_issue..."
  105. XX    @echo " " > mail_issue
  106. XX    @echo " digest_name='`cat .DIGESTNAME`'" >> mail_issue
  107. XX    @echo "          to='`cat .DIGESTADDR`'" >> mail_issue
  108. XX    @cat mail.issue.m >> mail_issue
  109.  
  110. XXvolume_number: 
  111. XX    @echo 'Creating volume_number file...'
  112. XX    @echo 1 > volume_number
  113.  
  114. XXclean:
  115. XX    /bin/rm -f .DIGESTNAME .DIGESTADDR .MODERATOR \
  116. XX    .MOD_ADDR digest.tail issue digest.title \
  117. XX    mail.digest mail_issue volume_number center mydate readword
  118.  
  119. @//E*O*F Makefile//
  120. chmod u=rw,g=rw,o=rw Makefile
  121.  
  122. echo x - center.1
  123. sed 's/^XX//' > "center.1" <<'@//E*O*F center.1//'
  124. XX.TH CENTER 1L 
  125. XX.ad b
  126. XX.SH NAME
  127. XXcenter \- read stdin, output each line centered in 80 cols
  128. XX.SH SYNOPSIS
  129. XX.B center
  130. XX< text > centered-text
  131. XX.SH HP-UX COMPATIBILITY
  132. XX.TP 10
  133. XXLevel:
  134. XXHP-UX/USER CONTRIBUTED
  135. XX.TP
  136. XXOrigin:
  137. XXHewlett-Packard Laboratories
  138. XX.SH DESCRIPTION
  139. XX.I Center
  140. XXis a simple program that is useful within shell scripts.  There
  141. XXare no doubt millions of `better' ways to accomplish what
  142. XXthis program does, but it does work!
  143. XX.SH EXAMPLE
  144. XX.P
  145. XXLet's assume we're in "sh";
  146. XX.nf
  147.  
  148. XX        $ name="John Doe"
  149. XX        $ echo $name
  150. XX        John Doe
  151. XX        $ name1=`echo $name | center`
  152. XX        $ echo $name1
  153. XX                                John Doe
  154. XX        $
  155.  
  156. XX.fi
  157. XX.SH AUTHOR
  158. XXDave Taylor, Hewlett-Packard Laboratories
  159. XX.SH "SEE ALSO"
  160. XXdigest(1)
  161. @//E*O*F center.1//
  162. chmod u=rw,g=r,o=r center.1
  163.  
  164. echo x - center.c
  165. sed 's/^XX//' > "center.c" <<'@//E*O*F center.c//'
  166. XX/**            center.c         **/
  167.  
  168. XX/** Simple program that filters stdin to stdout centering each line
  169. XX    it reads.  For batch/shell script processing, mostly. **/
  170.  
  171. XX#include <stdio.h>
  172.  
  173. XXmain()
  174. XX{
  175. XX    char buffer[100];
  176. XX    register int i;
  177.  
  178. XX    while (gets(buffer, 100) != NULL) {
  179. XX      for (i = 0; i < (80-strlen(buffer))/2; i++)
  180. XX        putchar(' ');
  181. XX      printf("%s\n", buffer);
  182. XX    }
  183. XX}
  184. @//E*O*F center.c//
  185. chmod u=rw,g=r,o=r center.c
  186.  
  187. echo x - digest.1
  188. sed 's/^XX//' > "digest.1" <<'@//E*O*F digest.1//'
  189. XX.TH DIGEST 1L 
  190. XX.ad b
  191. XX.SH NAME
  192. XXdigest \- tools to help maintain a mailing list/digest
  193. XX.SH HP-UX COMPATIBILITY
  194. XX.TP 10
  195. XXLevel:
  196. XXHP-UX/USER CONTRIBUTED
  197. XX.TP
  198. XXOrigin:
  199. XXHewlett-Packard Laboratories
  200. XX.SH DESCRIPTION
  201. XXThe
  202. XX.I digest
  203. XXsystem is composed of a number of programs and scripts;
  204. XX.nf
  205.  
  206. XX  Makefile            - to customize all the scripts, etc
  207. XX  center.c            - to center lines for formatting
  208. XX  center.1            -   manual entry for \fIcenter\fR
  209. XX  digest.all          - script to create an individual digest
  210. XX  digest.awk          - awk script to `massage' mailboxes
  211. XX  issue.master        - master copy of issue script
  212. XX  mail.digest.master  - master copy of mail.digest script
  213. XX  mail_issue.master   - master copy of mail_issue script
  214. XX  mydate.c            - program for `nice' date strings
  215. XX  mydate.1            -   manual entry for \fImydate\fR
  216. XX  readword.c          - dumb program for reading line from stdin
  217.  
  218. XX.fi
  219. XXWhen the \fImake\fR is done, a number of other files will appear
  220. XXand will comprise the full \fIdigest\fR script and mailing system;
  221. XX.nf
  222.  
  223. XX  DIGEST_ALIAS_ADDRESS - the address you use to send mail to everyone
  224. XX  DIGEST_NAME          - the full name of the digest
  225. XX  MODERATOR            - the full name of the moderator
  226. XX  MODERATOR_ADDRESS    - the email addres of MODERATOR
  227. XX  center               - executable version of center.c
  228. XX  digest.tail          - localized copy of digest.tail
  229. XX  issue                - localized copy of issue
  230. XX  mail.digest          - localized copy of mail.digest
  231. XX  mail_issue           - localized copy of mail_issue 
  232. XX  mydate               - executable version of mydate.c
  233. XX  readword             - executable version of readword.c
  234. XX  volume_number        - file used to autoincrement issues
  235.  
  236. XX.fi
  237. XXThe easiest way to see how they all interact is by example...
  238. XX.SH EXAMPLE
  239. XXLet's say that we want to create a new mailing list called
  240. XXcalled "Snail-Fans Digest", and we've already created the
  241. XXaliases "snail-fans-request" and "snail-fans" as the mail
  242. XXaddresses for requests to join the list/submit articles and
  243. XXto send mail to everyone in the group, respectively.
  244. XX.P
  245. XXWe could then type...[user input in \fBbold face\fR, comments in 
  246. XXsquare brackets like this];
  247. XX.nf
  248.  
  249. XX  $ \fBmake all\fR
  250.  
  251. XX    /bin/cc -O readword.c -o readword [for interactive makefile]
  252.  
  253. XX The name of the digest: \fBSnail-Fans Digest\fR
  254. XX The alias you'll use for sending it out: \fBsnail-fans\fR
  255. XX The full name of the moderator: \fBJohn Q. Public\fR
  256. XX The mailing address of the moderator: \fBsnail-fans-request\fR
  257.  
  258. XX     /bin/cc -O center.c -o center
  259. XX    /bin/cc -O mydate.c -o mydate
  260.  
  261. XX Creating digest.tail...
  262. XX Creating issue script...
  263. XX Creating mail.digest...
  264. XX Creating mail_issue...
  265. XX Creating volume_number file...
  266. XX digest system ready to go...
  267.  
  268. XX  $ \fBmore digest.tail\fR
  269.  
  270. XX  -------------------------------------
  271. XX 
  272. XX  To join this group or have your thoughts in the next issue, please
  273. XX  send electronic mail to John Q. Public at the following address;
  274. XX   
  275. XX      snail-fans-request
  276. XX 
  277. XX  *********************
  278. XX  End of Snail-Fans Digest
  279. XX  *********************
  280.  
  281. XX  $ \fBhead issue\fR
  282. XX 
  283. XX   digest_name='Snail-Fans Digest'
  284.  
  285. XX  # ISSUE  - Shell script creates a new issue of a mailing-list Digest.
  286. XX  #          To do this it creates a new title file then calls the digest.all
  287. XX  #          program to summarize the mailings.  It then drops you into the
  288. XX  #          editor to modify the subject headers, if desired.  Upon leaving
  289. XX  #          it then starts up the batchmail program in the background and
  290. XX  #          exits.
  291. XX  #
  292.  
  293. XX  $ \fBhead mail.digest\fR
  294. XX 
  295. XX   digest_name='Snail-Fans Digest'
  296. XX  
  297. XX  # mail_issue - This shell script mails out the previously created digest...
  298. XX  #
  299. XX  
  300. XX         digest="outbound.digest"
  301. XX        archive="Digest."
  302. XX         volume="volume_number"
  303. XX  
  304.  
  305. XX  $ \fBhead mail_issue\fR
  306. XX 
  307. XX   digest_name='Snail-Fans Digest'
  308. XX            to='snail-fans'
  309. XX  
  310. XX  # mail_issue - This shell script mails out the previously created digest...
  311. XX  #
  312. XX  
  313. XX         digest="outbound.digest"
  314. XX        archive="Digest."
  315. XX         volume="volume_number"
  316.  
  317.  
  318. XX  $ \fBmore volume_number\fR
  319.  
  320. XX  1
  321.  
  322. XX.fi
  323. XXThat's an idea of the files it creates.  Now let's actually send out
  324. XXan issue of the digest!
  325. XX.P
  326. XXFirst off, a few administration details - the \fIdigest\fR system 
  327. XXassumes that you use \fIoutbound\fR as the name of the mailbox that
  328. XXall outbound mail is queued in (note that no processing whatsoever
  329. XXneed be done beforehand on the mailbox) and that you won't mind
  330. XXsaving back issues as Digest.\fIn\fR where \fIn\fR is the number of
  331. XXthe digest...the most recently mailed digest mailbox is also saved
  332. XX(until the next mailing) as \fIoutbound.last\fR.
  333. XX.P
  334. XX.nf
  335.  
  336. XX  $ \fBcat outbound\fR
  337.  
  338. XX  From jqpublic Mon Jun  2 17:40:31 1986
  339. XX  To: jqpublic
  340. XX  Date: Mon Jun 2 17:40:31 1986 PST
  341. XX  Subject: Welcome to the Snail Fans Digest!
  342.  
  343. XX  Just a short hello to welcome everyone to the list and
  344. XX  to try out the digest software.
  345.  
  346. XX  Please let me know if you have any problems!
  347.  
  348. XX                -- JQ
  349.  
  350. XX  [ now we can actually send it out... ]
  351.  
  352. XX  $ \fBissue\fR
  353.  
  354. XX  Creating Snail-Fans Digest, Number 1
  355. XX 
  356. XX  Extracting all the 'subject' lines...
  357. XX 
  358. XX  ...feeding the file to awk...
  359. XX 
  360. XX  [your favorite editor is then invoked with the ready-to-be-sent
  361. XX   digest, for a final pass through (recommended)]
  362.  
  363. XX  Are you sure you want to send this issue out now? (y/n) \fBno\fR
  364. XX  just type "mail_issue" when you're ready to mail it out!
  365.  
  366. XX  [since we cancelled the actual mailing, let's look at the digest
  367. XX   it created...]
  368.  
  369. XX  $ \fBcat outbound.digest\fR
  370. XX 
  371. XX                          Snail-Fans Digest, Number 1
  372. XX 
  373. XX                             Monday, June 2nd 1986
  374. XX 
  375. XX  Today's Topics:
  376. XX 
  377. XX                       Welcome to the Snail Fans Digest!
  378. XX  ----------------------------------------------------------------------
  379. XX 
  380. XX  Date: Mon Jun 2 17:40:31 1986 PST
  381. XX  Subject: Welcome to the Snail Fans Digest!
  382. XX  From: jqpublic
  383.  
  384. XX  Just a short hello to welcome everyone to the list and
  385. XX  to try out the digest software.
  386.  
  387. XX  Please let me know if you have any problems!
  388.  
  389. XX                -- JQ
  390. XX 
  391. XX  -------------------------------------
  392. XX 
  393. XX  To join this group or have your thoughts in the next issue, please
  394. XX  send electronic mail to John Q. Public at the following address;
  395. XX 
  396. XX      snail-fans-request
  397. XX 
  398. XX  *********************
  399. XX  End of Snail-Fans Digest
  400. XX  *********************
  401. XX   
  402. XX  $ \fBmail_issue\fR
  403.  
  404. XX  Mailing Snail-Fans Digest, Number 1
  405. XX 
  406. XX  $
  407.  
  408. XX.fi
  409. XXPretty slick, eh?  In practice, maintaining a mailing list is
  410. XXmostly maintaining the actual addresses themselves.  The overhead
  411. XXof creating a digest (etc) is all avoided.
  412. XX.SH AUTHOR
  413. XXDave Taylor, Hewlett-Packard Laboratories
  414. XX.SH "SEE ALSO"
  415. XXawk(1), center(1), mydate(1), mailx(1), sendmail(1).
  416. @//E*O*F digest.1//
  417. chmod u=rw,g=r,o=r digest.1
  418.  
  419. echo x - digest.all
  420. sed 's/^XX//' > "digest.all" <<'@//E*O*F digest.all//'
  421.  
  422. XX#                DIGEST-ALL
  423. XX#
  424. XX# This shell script is to help create a 'digest' suitable for mailing out
  425. XX#    of all messages in a given mailbox...
  426. XX#
  427. XX# Dave Taylor, Hewlett-Packard Laboratories
  428.  
  429. XX    awk_script="digest.awk"
  430.  
  431. XXif [ $# -ne 4 ]
  432. XXthen
  433. XX  echo "Usage: $0 <header> <mailbox-name> <digest-name> <tail>"
  434. XX  exit 1
  435. XXfi
  436.  
  437. XXif [ ! -r $1 -o ! -r $4 ]
  438. XXthen
  439. XX  echo "$0: Can't find the header and/or tail files!"
  440. XX  exit 2
  441. XXfi
  442.  
  443. XXif [ ! -r $awk_script ]
  444. XXthen
  445. XX  echo "$0: Can't find the AWK script I need."
  446. XX  exit 2
  447. XXfi
  448.  
  449. XXif [ ! -r $2 ]
  450. XXthen
  451. XX  echo "$0: Can't find specified mailbox - $2"
  452. XX  exit 3
  453. XXfi
  454.  
  455. XXif [ -z $2 ]
  456. XXthen
  457. XX  echo "$0: Mailbox $2 is EMPTY!"
  458. XX  exit 4
  459. XXfi
  460.  
  461. XXif [ -r $3 ]
  462. XXthen
  463. XX  if [ "`echo -n hi | grep n`" = "" ]        # can echo use "-n" ??
  464. XX  then
  465. XX    echo -n "$0: File $3 exists!  Overwrite it? (y/n) "      # yes!
  466. XX  else
  467. XX    echo "$0: File $3 exists!  Overwrite it? (y/n) \\c"      #  no!
  468. XX  fi
  469. XX  read answer junk
  470. XX  if [ "$answer" = "y" -o "$answer" = "yes" ]
  471. XX  then
  472. XX    echo "$0: removing current copy of file $3..."
  473. XX    rm -f $3
  474. XX  else
  475. XX    echo "$0: Digest processing cancelled!"
  476. XX    exit 5
  477. XX  fi
  478. XXfi
  479.  
  480. XX# Now let's try to do something!
  481.  
  482. XXcat $1 > $3
  483.  
  484. XX# first collect all the 'subject' lines at the top of the file...
  485.  
  486. XXecho ' '
  487. XXecho "Extracting all the 'subject' lines..."
  488.  
  489. XXegrep -e "^Subject:" $2 | sed 's/Subject://' | center >> $3
  490.  
  491. XXecho ' '
  492.  
  493. XX# now digest the file...
  494.  
  495. XXecho "...feeding the file to awk..."
  496.  
  497. XXcat $2 | awk -f $awk_script - >> $3
  498.  
  499. XXcat $4 >> $3
  500. XX 
  501. XXecho ' '
  502. XXexit 0
  503. @//E*O*F digest.all//
  504. chmod u=rwx,g=rx,o=rx digest.all
  505.  
  506. echo x - digest.awk
  507. sed 's/^XX//' > "digest.awk" <<'@//E*O*F digest.awk//'
  508. XX#
  509. XX# Awk Script called by 'digest'.  See DIGEST(1)
  510. XX#
  511. XX# Version two - sucks in the '>From' lines too...
  512. XX#               (guarantees a "valid" return address!)
  513.  
  514. XXBEGIN {
  515. XX    message = 0;
  516. XX    last = "this should never be matched"
  517. XX    in_header = 1;
  518. XX        have_from = 0;
  519. XX      }
  520.  
  521. XX$1 ~ /^From$/     {  if (message == 0) {
  522. XX              print "----------------------------------------------------------------------"
  523. XX              print " "
  524. XX            }
  525. XX            else {
  526. XX              print "------------------------------"
  527. XX                  print " "
  528. XX               }
  529. XX            message++;
  530. XX                in_header = 1;
  531. XX                from = $2;
  532. XX            parse_count = 0;
  533. XX                have_from = 0;
  534. XX            last = "we should have a hard time matching this, too"
  535. XX             }
  536.  
  537. XX$1 ~ /^From:/    { if (in_header) print $0; 
  538. XX           have_from = 1 }
  539. XX$1 ~ /^>From/     { parse_count++;
  540. XX           address = $2
  541. XX           if (parse_count > 1)
  542. XX             from = from"!"$10
  543. XX               else
  544. XX             from = $10
  545. XX         }
  546. XX$1 ~ /^Subject:/ { if (in_header) print $0 }
  547. XX$1 ~ /^Date:/    { if (in_header) print $0 }
  548.  
  549. XXlength($0) < 2   { 
  550. XX               if (in_header == 1)
  551. XX                 if (have_from == 0)
  552. XX               print "From: "from"!"address
  553.  
  554. XX           if ($0 != last)
  555. XX             print $0
  556. XX           in_header = 0
  557. XX           last = $0
  558. XX             }
  559.  
  560. XXin_header == 0   { if ($0 != last) 
  561. XX                     print $0
  562. XX           last = $0 
  563. XX         }
  564. @//E*O*F digest.awk//
  565. chmod u=rw,g=r,o=r digest.awk
  566.  
  567. echo x - issue.master
  568. sed 's/^XX//' > "issue.master" <<'@//E*O*F issue.master//'
  569.  
  570. XX# ISSUE  - Shell script creates a new issue of a mailing-list Digest.
  571. XX#          To do this it creates a new title file then calls the digest.all
  572. XX#          program to summarize the mailings.  It then drops you into the
  573. XX#          editor to modify the subject headers, if desired.  Upon leaving
  574. XX#          it then starts up the batchmail program in the background and
  575. XX#          exits.
  576. XX#
  577. XX# (C) 1985, Dave Taylor, Hewlett-Packard Laboratories
  578. XX#
  579.  
  580. XX  titles=digest.title
  581. XX     vol=volume_number
  582. XX    tail=digest.tail
  583.  
  584. XXif [ ! -r outbound ]
  585. XXthen
  586. XX  echo Nothing queued to go out.
  587. XX  exit 0
  588. XXfi
  589.  
  590. XXecho " "
  591. XXecho "Creating $digest_name, Number `cat $vol`"
  592.  
  593. XXrm -f $titles
  594. XXecho ' ' > $titles
  595. XXecho "$digest_name, Number `cat $vol`" | center >> $titles
  596. XXecho " " >> $titles
  597. XXmydate notime | center >> $titles
  598. XXecho ' ' >> $titles
  599. XXecho "Today's Topics:" >> $titles
  600. XXecho ' ' >> $titles
  601.  
  602. XXdigest.all $titles outbound outbound.digest $tail
  603. XXmv outbound outbound.last
  604.  
  605. XXif [ "$EDITOR" = "" ]
  606. XXthen
  607. XX  /bin/vi outbound.digest
  608. XXelse
  609. XX  $EDITOR outbound.digest
  610. XXfi
  611.  
  612. XXecho ' '
  613. XXecho ' '
  614. XXif [ "`echo -n hi | grep n`" = "" ]    # can echo deal with -n ?
  615. XXthen
  616. XX  echo -n "Are you sure you want to send this issue out now? (y/n) "
  617. XXelse
  618. XX  echo "Are you sure you want to send this issue out now? (y/n) \\c"
  619. XXfi
  620. XXread answer junk
  621.  
  622. XXif [ "$answer" = "yes" -o "$answer" = "y" ]
  623. XXthen
  624. XX  echo " "
  625. XX  rm -f $issue_log
  626. XX  echo "starting up mail daemon..."
  627.  
  628. XX  mail_issue
  629.  
  630. XX  echo " "
  631. XXelse
  632. XX  echo "just type \"mail_issue\" when you're ready to mail it out!"
  633. XXfi
  634.  
  635. XXexit 0
  636. @//E*O*F issue.master//
  637. chmod u=rw,g=r,o=r issue.master
  638.  
  639. echo x - mail.digest.m
  640. sed 's/^XX//' > "mail.digest.m" <<'@//E*O*F mail.digest.m//'
  641.  
  642. XX# mail_issue - This shell script mails out the previously created digest...
  643. XX#
  644.  
  645. XX       digest="outbound.digest"
  646. XX      archive="Digest."
  647. XX       volume="volume_number"
  648.  
  649. XX# does the file exist???
  650.  
  651. XXif [ -r $digest ]
  652. XXthen
  653. XX  volnum=`cat $volume`
  654.  
  655. XX  (mailx -s "$digest_name, #$volnum" $to < $digest
  656.  
  657. XX  mv $digest $archive$volnum;
  658. XX  rm -f $digest;
  659.  
  660. XX  rm -f $volume;
  661. XX  echo Incrementing volume number..
  662. XX  echo `expr $volnum + 1` > $volume) > $log 2>&1 &
  663. XX  
  664. XXfi
  665.  
  666. XXexit 0
  667. @//E*O*F mail.digest.m//
  668. chmod u=rw,g=r,o=r mail.digest.m
  669.  
  670. echo x - mail.issue.m
  671. sed 's/^XX//' > "mail.issue.m" <<'@//E*O*F mail.issue.m//'
  672.  
  673. XX# Front end for mailing out the digest...
  674.  
  675. XX            vol=volume_number
  676.  
  677. XXecho "Mailing \"$digest_name, Volume `cat $vol`\""
  678.  
  679. XXexec nohup mail.digest
  680. @//E*O*F mail.issue.m//
  681. chmod u=rw,g=r,o=r mail.issue.m
  682.  
  683. echo x - mydate.1
  684. sed 's/^XX//' > "mydate.1" <<'@//E*O*F mydate.1//'
  685. XX.TH MYDATE 1L 
  686. XX.ad b
  687. XX.SH NAME
  688. XXmydate \- readable date format
  689. XX.SH SYNOPSIS
  690. XX.B mydate
  691. XX.br
  692. XX.B "mydate notime"
  693. XX.SH HP-UX COMPATIBILITY
  694. XX.TP 10
  695. XXLevel:
  696. XXHP-UX/USER CONTRIBUTED
  697. XX.TP
  698. XXOrigin:
  699. XXHewlett-Packard Laboratories
  700. XX.SH DESCRIPTION
  701. XX.I Mydate
  702. XXis a simple program that displays the local date in a much more
  703. XXreadable format than possible by the \fIdate\fR(1) program.
  704. XXThere are two ways to use it, both exemplified below.
  705. XX.P
  706. XXThis is most useful for use within scripts.
  707. XX.SN EXAMPLE
  708. XX.nf
  709.  
  710. XX    % date 
  711. XX    Mon Jun  2 18:35:24 PDT 1986
  712.  
  713. XX    % mydate
  714. XX    Monday, June 2nd 1986 at 6:35 pm
  715.  
  716. XX    % mydate notime
  717. XX    Monday, June 2nd 1986
  718. XX         
  719. XX.fi
  720. XX.SH AUTHOR
  721. XXDave Taylor, Hewlett-Packard Laboratories
  722. XX.SH "SEE ALSO"
  723. XXdate(1), digest(1)
  724. @//E*O*F mydate.1//
  725. chmod u=rw,g=r,o=r mydate.1
  726.  
  727. echo x - mydate.c
  728. sed 's/^XX//' > "mydate.c" <<'@//E*O*F mydate.c//'
  729. XX/**        mydate.c        **/
  730.  
  731. XX/** This program outputs the date in the format:
  732. XX    DAY, MONTH DATE YEAR at HH:MM am|pm
  733. XX    ("Monday, January 17th, 1985 at 4:17 pm" for example)
  734. XX    or, with ANY parameters at all;
  735. XX    DAY, MONTH DATE YEAR
  736. XX        without any 'time' string...
  737.  
  738. XX    Dave Taylor, Colorado Networks Operation
  739. XX**/
  740.  
  741. XX#include <time.h>
  742. XX#include <stdio.h>
  743.  
  744. XX#define ampm(n)        (n > 12? n - 12 : n)
  745. XX#define am_or_pm(n)    (n > 12? "pm" : "am")
  746.  
  747. XXchar *dayname[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
  748. XX          "Friday", "Saturday", "" };
  749.  
  750. XXchar *monname[] = { "January", "February", "March", "April", "May", "June",
  751. XX          "July", "August", "September", "October", "November",
  752. XX          "December", ""};
  753.  
  754. XXmain(argc, argv)
  755. XXint argc;
  756. XXchar *argv[];
  757. XX{
  758. XX    struct tm *the_time;        /* Time structure, see CTIME(3C) */
  759. XX    char      *suffix();         /* digit suffix for date     */
  760. XX    long      junk;            /* time in seconds....         */
  761.  
  762. XX    junk = time(0);    /* this must be here for it to work! */
  763. XX    the_time = (struct tm * ) localtime(&junk);
  764. XX        
  765. XX    if (argc == 1)      /* normal format... */
  766. XX      printf("%s, %s %d%s %d at %d:%02d %s\n",
  767. XX         dayname[the_time->tm_wday],    /* weekday */
  768. XX         monname[the_time->tm_mon],    /* month   */
  769. XX         the_time->tm_mday,        /* day     */
  770. XX         suffix(the_time->tm_mday),    /* suffix  */
  771. XX         the_time->tm_year + 1900,    /* year    */
  772. XX         ampm(the_time->tm_hour),    /* hour    */
  773. XX         the_time->tm_min,        /* minute  */
  774. XX         am_or_pm(the_time->tm_hour));    /* am | pm */
  775. XX    else             /* sccs (retch) format */
  776. XX      printf("%s, %s %d%s %d\n",
  777. XX         dayname[the_time->tm_wday],    /* weekday */
  778. XX         monname[the_time->tm_mon],    /* month   */
  779. XX         the_time->tm_mday,        /* day     */
  780. XX         suffix(the_time->tm_mday),    /* suffix  */
  781. XX         the_time->tm_year + 1900);    /* year    */
  782. XX}
  783.  
  784. XXchar *suffix(day)
  785. XXint day;
  786. XX{
  787. XX    /** this routine returns the suffix appropriate for the
  788. XX        specified number to make it an ordinal number.  ie,
  789. XX        if given '1' it would return 'st', and '2' => 'nd'
  790. XX    **/
  791.  
  792. XX    static char buffer[10];
  793. XX    register int digit;
  794.  
  795. XX    digit = day % 10;
  796.  
  797. XX    if (digit == 0 || digit > 3 || (day > 10 && day < 14))
  798. XX      strcpy(buffer,"th");
  799. XX    else if (digit == 1)
  800. XX      strcpy(buffer,"st");
  801. XX    else if (digit == 2)
  802. XX      strcpy(buffer, "nd");
  803. XX    else
  804. XX      strcpy(buffer, "rd");
  805.  
  806. XX    return( (char *) buffer);
  807. XX}
  808. @//E*O*F mydate.c//
  809. chmod u=rw,g=r,o=r mydate.c
  810.  
  811. echo x - readword.c
  812. sed 's/^XX//' > "readword.c" <<'@//E*O*F readword.c//'
  813. XX/**            readword.c            **/
  814.  
  815. XX/* Stupid little program to read a line from stdin and write it to the
  816. XX   specified filename.  This SHOULD be equivalent to
  817.  
  818. XX    read var ; echo $var > filename
  819.  
  820. XX   but that doesn't work from within Makefiles *sigh*
  821.  
  822. XX*/
  823.  
  824. XX#include <stdio.h>
  825.  
  826. XXmain(argc, argv)
  827. XXint argc;
  828. XXchar *argv[];
  829. XX{
  830. XX    FILE *file_device;    /* file descriptor... */
  831. XX    char  buffer[100];    /* and input buffer   */
  832.  
  833. XX    /** first lets check the starting arguments... **/
  834.  
  835. XX    if (argc != 2) {
  836. XX      fprintf(stderr,"Usage: readword <filename>\n");
  837. XX      exit(1);
  838. XX    }
  839.  
  840. XX    /** can we open the file for writing??? **/
  841.  
  842. XX    if ((file_device = fopen(argv[1], "w")) == NULL) {
  843. XX      fprintf(stderr,"Cannot open file %s for writing!\n", argv[1]);
  844. XX      exit(2);
  845. XX    }
  846.  
  847. XX    /** okay...read and write the input **/
  848.  
  849. XX    gets(buffer);
  850.  
  851. XX    fputs(buffer, file_device);
  852.  
  853. XX    /** close the file... **/
  854.  
  855. XX    fclose(file_device);
  856.  
  857. XX    /** and we're done! **/
  858.  
  859. XX    exit(0);
  860. XX}
  861. @//E*O*F readword.c//
  862. chmod u=rw,g=rw,o=rw readword.c
  863.  
  864. exit 0
  865.