#!/usr/bin/perl
#   Kyoma TAKAHASHI  1999.09.30

$domain = '@ep.sci.hokudai.ac.jp';

open (GATEUL,"/usr/local/bin/gate-user-list stable |");

while (<GATEUL>) {
chop ( $user = $_ );

if ( $user ne '' ) {
        open (GATEUS,"/usr/local/bin/gate-user-show $user |");
        while (<GATEUS>) { if (/type/) { ($typeq) = /type: (.*)/; } }
        close (GATEUS);

        if ( $typeq eq 'person' ) {
        $address = $user.$domain;
        system "/usr/local/bin/ezmlm/ezmlm-sub ~alias/accountholder/ $address";
        }
}
}
close (GATEUL);

open (GATEUL,"/usr/local/bin/gate-user-list defunct |");

while (<GATEUL>) {
chop ( $user = $_ );

if ( $user ne '' ) {
        open (GATEUS,"/usr/local/bin/gate-user-show $user |");
        while (<GATEUS>) { if (/type/) { ($typeq) = /type: (.*)/; } }
        close (GATEUS);

        if ( $typeq eq 'person' ) {
        $address = $user.$domain;
        system "/usr/local/bin/ezmlm/ezmlm-unsub ~alias/accountholder/ $address";
        }
}
}
close (GATEUL);

system "/usr/local/bin/gate-user-list defunct | /usr/local/bin/list-2-ezmlm-unsub ~alias/accountholder/";

