[CLUE-Cert] scripting fun

David_Holz at ca10.uscourts.gov David_Holz at ca10.uscourts.gov
Tue Jul 3 10:04:58 MDT 2001


     This may be too simple an idea but here goes.
     
     If all the users's home directories are in the same place (i.e. 
     /home/user1, /home/user2, ...):
     
     cd /home
     for X in `ls -d user[0-9]*`
     do
        whatever_change $X              ### i.e. chgrp us /home/$X ###
     done
     
                David


______________________________ Reply Separator _________________________________
Subject: [CLUE-Cert] scripting fun
Author:  clue-cert at clue.denver.co.us at ~Internet2
Date:    7/3/2001 7:01 AM


Hello all,
     
When I setup a sysad class I make groups us, them, exclusiv and secret. 
I need to add students to the us and exclusiv groups. I do this by using 
a "for" loop.
     
for User in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 
do
usermod -G us,exclusiv s$User
done
     
A simple 4 line script. Now what I would like to do is get rid of the 1 
2 3 ... line of the for loop and do something like
     
cat /etc/password | xargs grep s* 
for User in $SUser
do
usermod -G us,exclusiv s$User
done
     
I know what the users are but would like to automate the process a 
little more. There are goals that need to be met.
     
1. Small script. 5 -10 lines at max. make it easy to remember.
2. Done in memory. While we could do this with temp files we want to do 
this without. makes it more fun.
     
Why would we do something like this? How about that a development group 
is put together to do some work. They will work on project X and will 
need to access the same documents. 
     
     
     
     
     
/etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:
daemon:x:2:2:daemon:/sbin:
adm:x:3:4:adm:/var/adm:
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown 
halt:x:7:0:halt:/sbin:/sbin/halt
operator:x:11:0:operator:/root:
ftp:x:14:50:FTP User:/var/ftp:
sympa:x:89:89:Sympa Mailing list manager:/var/lib/sympa:/bin/bash 
nobody:x:99:99:Nobody:/:
alias:x:400:401:qmail alias user:/var/qmail/alias:/bin/true 
s1:x:501:501::/home/s1:/bin/bash
s2:x:502:502::/home/s2:/bin/bash
s3:x:503:503::/home/s3:/bin/bash
s4:x:504:504::/home/s4:/bin/bash
s5:x:505:505::/home/s5:/bin/bash
     
/etc/group
root:x:0:root
bin:x:1:root,bin,daemon
daemon:x:2:root,bin,daemon
sys:x:3:root,bin,adm
adm:x:4:root,adm,daemon
tty:x:5:
disk:x:6:root
lp:x:7:daemon,lp
mem:x:8:
kmem:x:9:
wheel:x:10:root
us:x:401:
them:x:402:
excluciv:403:
secret:404:
s1:x:501:
s2:x:502:
s3:x:503:
s4:x:504:
s5:x:505:
_______________________________________________ 
CLUE-Cert mailing list
CLUE-Cert at clue.denver.co.us
http://clue.denver.co.us/mailman/listinfo/clue-cert



More information about the clue-cert mailing list