[Spread-users] send text to spread group from command line?

George Schlossnagle george at omniti.com
Fri Aug 17 14:05:34 EDT 2001


There's not one that ships with Spread, but it's simple enough to write.
Here's a short one:


#include "stdio.h"
#include "stdlib.h"
#include <unistd.h>
#include "string.h"
#include "sp.h"

void usage(char *s)
{
    fprintf(stderr, "%s -g <group> -s server\n", s);
}

int main(int argc, char **argv)
{
    char *server = 0;
    char *group = 0;
    char line[1024];
    char privatename[MAX_GROUP_NAME];
    char privategroup[MAX_GROUP_NAME];
    int retval;
    int getoption;
    mailbox mbox;

    while((getoption = getopt(argc, argv, "g:s:h:")) != -1) {
        switch(getoption)
        {
            case 'g':
                group = optarg;
                break;
            case 's':
                server = optarg;
                break;
            default:
                usage(argv[0]);
                return -1;
                break;
        }
    }
    if( group == 0 || server == 0) {
        usage(argv[0]);
        return -1;
    }
    snprintf(privatename, MAX_GROUP_NAME, "sp_client_%d", getpid());
    if((retval = SP_connect(server, privatename, 0, 0, &mbox, privategroup))
<
0 )
    {
        SP_error(retval);
        return -1;
    }
    while(fgets(line, 1024, stdin)) {
        fprintf(stderr, "%s", line);
        if((retval = SP_multicast( mbox, RELIABLE_MESS, group, 1,
strlen(line),
            line)) < 0)
        {
            SP_error(retval);
            return -1;
        }
    }
}



name it sp_client.c and compile it with
gcc -c sp_client.c
gcc -o sp_client sp_client.o -lsp


----- Original Message -----
From: "Monte Ohrt" <monte at ispi.net>
To: "spread mailing list" <spread-users at lists.spread.org>
Sent: Friday, August 17, 2001 12:39 PM
Subject: [Spread-users] send text to spread group from command line?


> Is there a way to send text to a spread group from the command line? I
> guess I'm asking if there is a non-interactive client that can take
> input like so:
>
> spread_client -g groupname -s 4803 < input.txt
>
> or:
>
> echo input.txt | spread_client -g groupname -s 4803
>
> If there _is_ such a client, could this be used in apache for spreading
> the error_logs instead of the perl script that comes with
> mod_log_spread? I'm trying to avoid perl :-)
>
> ErrorLog = "|/path/to/spread_client -g group -s port"
>
> --
> Monte Ohrt <monte at ispi.net>
> http://www.ispi.net/
>
>
> _______________________________________________
> spread-users mailing list
> spread-users at lists.spread.org
> http://lists.spread.org/mailman/listinfo/spread-users
>







More information about the Spread-users mailing list