acctmod-sympa.sh

acctmod-sympa.sh

#!/bin/sh
if [ "$1" = "" ]; then exit 1 ; fi
if [ "$2" = "" ]; then exit 1 ; fi
n1=`expr index $1 "@"`
if [ $n1 = 0 ]; then exit 1 ; fi
n2=`expr index $2 "@"`
if [ $n2 = 0 ]; then exit 1 ; fi 
SAVEIFS=$IFS
IFS="
"
cou1=`mysql -u root -p*** -e "use sympa; select count(*) from subscriber_table where user_subscriber = '$1'" | sed -n '2p';`
if [ "$cou1" -eq "0" ]; then exit 1 ; fi

vlist=`mysql -u root -p*** -e "use sympa; select list_subscriber from subscriber_table where user_subscriber = '$1'" | grep -v ^list_subscriber$;`
for f in $vlist
do
cou2=`mysql -u root -p*** -e "use sympa; select count(*) from subscriber_table where list_subscriber='$f' and user_subscriber = '$2'" | sed -n '2p';`
if [ "$cou2" -eq "0" ]
then
mysql -u root -p*** -e "use sympa; update subscriber_table set user_subscriber = '$2' where list_subscriber='$f' and user_subscriber = '$1'";
echo "$f: $1 -> $2"
fi
done

IFS=$SAVEIFS

你可能感兴趣的:(acctmod-sympa.sh)