#!/bin/sh
if [ $# -ne 1 ]; then
    echo "usage: bwrite user@bitnetnode" 1>&2
    exit 1
fi
echo $1 | egrep -s '^[^@]+@[^@\.]+$'
if [ $? -ne 0 ]; then
    echo "usage: bwrite user@bitnetnode ('bitnetnode' is required -- no '.' in node name)" 1>&2
    exit 1
fi
echo $1 | tr a-z A-Z | egrep -s -v '^LISTSERV@|^NETSERV@|^MAILSERV@|^FILESERV@'
if [ $? -ne 0 ]; then
    echo "bwrite: can't send to LISTSERV or similar server addresses.  Use mail instead." 1>&2
    exit 1
fi
echo "(Long messages (> 10 lines) may be truncated or discarded by the server.)"
exec zwrite -n -c bgw -i $1 rcmd.charon
