From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17364 invoked from network); 7 Oct 1998 01:15:22 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 7 Oct 1998 01:15:22 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id VAA01566; Tue, 6 Oct 1998 21:07:00 -0400 (EDT) Resent-Date: Tue, 6 Oct 1998 21:06:53 -0400 (EDT) Message-ID: <19981006211316.A4791@astaroth.nit.gwu.edu> Date: Tue, 6 Oct 1998 21:13:16 -0400 From: Sweth Chandramouli To: zsh-users@math.gatech.edu Subject: Re: Null tilde expansions? Mail-Followup-To: zsh-users@math.gatech.edu References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=KsGdsel6WgEHnImy X-Mailer: Mutt 0.93.2i In-Reply-To: Resent-Message-ID: <"Fqsef3.0.0O.jwh6s"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1832 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu --KsGdsel6WgEHnImy Content-Type: text/plain; charset=us-ascii On Tue, Oct 06, 1998 at 11:16:28AM -0700, Greg Badros wrote: > exist (our sysadmins aren't good about eliminating users from groups > when the remove the user account). don't know about how to do what you want in zsh, but here's a quick perl script i whipped up a week ago to do what your sysadmins aren't doing. set $groupfile_out to something else at first, to test, since i don't want to be responsible for anything happening to your system. (this assumes you can either run this script as root or convince your admins to, of course...) -- sweth. -- Sweth Chandramouli IS Coordinator, The George Washington University / (202) 994 - 8521 (V) / (202) 994 - 0458 (F) * --KsGdsel6WgEHnImy Content-Type: application/x-perl Content-Description: Perl Script To Remove Non-Valid Users From /etc/group Content-Disposition: attachment; filename="fixgp.pl" #!/usr/local/bin/perl -w $passwdfile = "/etc/passwd"; $groupfile = "/etc/group"; $groupfile_out = ">/etc/group"; &mkuserlist; &fix_group_file; sub mkuserlist { $count = '0'; (open PASSWDFILE, $passwdfile) or die 'failed during opening of ', $passwdfile; @user_list = (); while () { chomp(($user_list[$count++]) = split(/:/,$_)); }; close PASSWDFILE; }; sub fix_group_file { &init_group_hash; &write_new_groupfile; }; sub init_group_hash { (open GROUPFILE, $groupfile) or die 'failed during open of ', $groupfile; while () { chomp(@tmp_array = split(/:/, $_)); $group_info = "$tmp_array[0]" . '::' . "$tmp_array[2]" . ':'; $user_count = '0'; GROUPMEMB: foreach $group_member (split(/,/, pop @tmp_array)) { foreach $user (@user_list) { if ($user eq $group_member) { if ($user_count++ == '0') { $group_info = $group_info . $group_member; } else { $group_info = $group_info . ',' . $group_member; }; next GROUPMEMB; }; }; }; push(@full_group_list, $group_info); }; close GROUPFILE; }; sub write_new_groupfile { (open GROUPFILE_OUT, $groupfile_out) or die 'failed during open of ', $groupfile_out; foreach $full_line ( @full_group_list ) { print GROUPFILE_OUT ($full_line, "\n"); }; }; --KsGdsel6WgEHnImy--