🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #37539

Re: SLRNPULL: Need info to crontab post

#37539
From: John E. Davis
Date: Thu, 11 Dec 1997 00:00
111 lines
3073 bytes
On 7 Dec 1997 22:55:55 GMT, Grey Cloak <greycloak@greycloak.access.one.net>
wrote:
>I am using slrnpull to read news off line. I need to be able to
>post a FAQ once a month. I planned on using crontab and a perl
>script to do this.
>
>I would like some info on the db needed to be updated so I can put
>the file into out.going and have slrnpull post it.

I am now posting the slrn-FAQ in the manner that you describe.  I use
a shell script that runs via cron.  Here is my shell script:

#! /bin/sh
cd /var/spool/news/news.mit.edu/out.going
new_msgid=`./genmsgid davis space.mit.edu`
old_msgid=`cat ./last_msgid.dat`
echo "Message-Id: $new_msgid" >  slrn-FAQ.x
echo "Supersedes: $old_msgid" >> slrn-FAQ.x
/bin/cat slrn-FAQ >> slrn-FAQ.x
/bin/mv slrn-FAQ.x X.slrn-FAQ
echo $new_msgid > ./last_msgid.dat
exit 0

The `genmsgid' program generates a message-id given two command line
parameters.  It is based on similar code I extracted from slrn:

#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <unistd.h>

static char *create_message_id (char *username, char *host)
{
   unsigned long pid, now;
   static unsigned char baseid[64];
   unsigned char *b, *t, tmp[32];
   char *chars32 = "0123456789abcdefghijklmnopqrstuv";
   static unsigned long last_now;

   while (1)
     {
	if ((host == NULL)
	    || ((time_t) -1 == time ((time_t *)&now)))
	  return NULL;

	if (now != last_now) break;
	sleep (1);
     }
   last_now = now;

   pid = (unsigned long) getpid ();
   now -= 0x28000000;

   b = baseid;
   t = tmp;
   while (now)
     {
	*t++ = chars32[now & 0x1F];
	now = now >> 5;
     }
   while (t > tmp)
     {
	t--;
	*b++ = *t;
     }
   *b++ = '.';

   t = tmp;
   while (pid)
     {
	*t++ = chars32[pid & 0x1F];
	pid = pid >> 5;
     }
   while (t > tmp)
     {
	t--;
	*b++ = *t;
     }

   *b++ = '.';
   t = (unsigned char *) username;
   if (t != NULL)
     while ((*t != 0) && (b < baseid + sizeof(baseid) - 1)) *b++ = *t++;
   *b = 0;

   return (char *) baseid;
}

int main (int argc, char **argv)
{
   char *s;

   if (argc != 3)
     {
	fprintf (stderr, "Usage: %s username host\n", argv[0]);
	return 1;
     }

   s = create_message_id (argv[1], argv[2]);
   if (s == NULL)
     {
	fprintf (stderr, "%s: failed to generate msgid.\n", argv[0]);
	return 1;
     }
   fprintf (stdout, "<%s@%s>\n", s, argv[2]);
   return 0;
}

Technical Details
Message-ID: <slrn68ur83.8be.davis@mygir.davis.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail
References: <slrn68mb8t.rh.greycloak@greycloak.access.one.net>

Show Full Headers
Complete Article Headers
Message-ID: <slrn68ur83.8be.davis@mygir.davis.net>
Subject: Re: SLRNPULL: Need info to crontab post
Date: Thu, 11 Dec 1997 00:00:00 +0000
From: davis@space.mit.edu (John E. Davis)
References: <slrn68mb8t.rh.greycloak@greycloak.access.one.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail
X-Deja-AN: 297198244
Organization: Center for Space Research
Newsgroups: news.software.readers