#!/bin/csh -f
#**********************************************************************
#         Copyright IBM Corporation 1988,1989 - All Rights Reserved
#         For full copyright information see: 'andrew/config/COPYRITE'
#**********************************************************************
# list-subscribe listname host.bitnet
# ?[POBBRunWarning]
# ?[POBBRunNotice]
if ($??0) then
	set EX=$0
else
	set EX="list-subscribe"
endif
if ($#argv < 2) then
	echo "Usage: $EX listname host.bitnet [-list|-digest] [andrew-listname]"
	exit(2)
endif
set DISTRIB=$1
set ANDYNAME=$1
set TO=LISTSERV@$2
shift
shift
set LOCADDR="arpalists"
while ($#argv > 0)
	if ( "$1" == "-list") then
		set LOCADDR="arpalists"
	else if ( "$1" == "-digest" ) then
		set LOCADDR="arpadigests"
	else
		set ANDYNAME=$1
	endif
	shift
end

echo "About to request ${TO} to subscribe ?[WorkstationCell] to list ${DISTRIB}, calling it ?[InternetRootName].${ANDYNAME} ."
set FN=/tmp/dogs$$
set FROM=${LOCADDR}+${ANDYNAME}@?[WorkstationCell]
set CC=?[LogBB].subscribe@?[WorkstationCell]

echo "Composing request notice in $FN..."
echo "Date: `?[arpadatepgm]`" > $FN
echo "From: $FROM" >> $FN
echo "To: $TO" >> $FN
echo "Subject: Please subscribe us" >> $FN
echo "CC: $CC" >> $FN
echo "" >> $FN
echo "SUBSCRIBE ${DISTRIB} Andrew Message System" >> $FN
echo "Now mailing the request..."
echo ?[queuemail] -f $FN -r "<$FROM>" -a $TO $CC
?[queuemail] -f $FN -r "<$FROM>" -a $TO $CC
set STAT=$status
if ($STAT != 0) then
	echo "Submission failed!  Exit status is $STAT; request left in $FN."
	exit(3)
endif
echo "Submitted OK."
rm -f $FN
