- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- AWK , uid and NIS
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2002 02:41 AM
тАО06-17-2002 02:41 AM
I have a text file of the following form, which is an output from "ls -l":
#cat fileList.txt
-rwx------ 1 chern oper 253 Jun 17 12:03 ChangeUID.csh
-rw-r--r-- 1 root oper 0 Jun 17 12:04 fileList.txt
-rwx------ 1 rlee oper 677 May 15 17:52 groups.bak
-rwx------ 1 wchan oper 775 May 14 14:27 groups.bak1
I had written a script to change the numeric ids of these users within this directory:
#cat ChangeUID.sh
foreach a (`cat fileList.txt`)
set uid=`id $3|awk '{print $1}'`
echo "uid = $uid"
switch ($uid)
case 0: chown 17190 $a
;;
case 1189:chown 1890 $a
;;
case 442: chown 3852 $a
;;
case 671: chown 1264 $a
;;
endsw
end
Users root, chern, rlee and wchan have their original uids as 0, 1189, 442, 671.
My question is:
1)Whenever this script is executed, the output is of the following :
uid = uid=0(root)
...... (infinitely)
It doesn't seem to change the old uids corresponding to the files in the firectory to the newly specified uid in the case statement.
Could anyone tell me how I should go about fixing this bug ?? and get the uids changed?
Also if the file-list contains different users needing to change their uids to some value, how can I do this in a more efficient manner?
2)Also, if the the /var/yp/src/passwd file were to be modified to include the new uids(in the NIS master), would this change be propogated to the NIS slave servers, and hence the NIS clients ?
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2002 03:28 AM
тАО06-17-2002 03:28 AM
Re: AWK , uid and NIS
your "foreach" is yanking every single WORD, it's not grabbing each line as you would like.
Try making your script an "awk" script.
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2002 03:36 AM
тАО06-17-2002 03:36 AM
Re: AWK , uid and NIS
Instead of the foreach use a while loop
while read $a $b $c $d .....
do
#whatever you will do
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2002 05:43 AM
тАО06-17-2002 05:43 AM
SolutionI tried to re-write yout script for Korn shell. The attached version will however only write the changes that it could perform: I find the script rather dangerous and leave it up to you to remove the comments in the case-structure. The ALLOWED_DIR should be set to the dir in which your files are.
You need to maintain the script yourself with regard to the user ids it should support. Hope it helps.
Regards John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2002 05:52 AM
тАО06-17-2002 05:52 AM
Re: AWK , uid and NIS
About the NIS part , you could go and alter the data in the NIS map however I would not advise you to do so , NIS map are made by the YPMAKE command and that should be used , propagation of maps doesn't happen automatically if you don't use YPMAKE , you have to use YPPUSH or YPXFR to push or pull the changed maps to any slave servers , also yp read the map at startup so changes are not atomattic you could need to start YPSERv and YPBIND to make it work , if you ghave no idea on th estructure of the NIS maps themselfs I wish to refer you to the O'Reilly NFS & NIS manual (i forgot the ISBN number) it explains not only th emap structure but also the update procedure of maps withing a master/slave environment for NIS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-17-2002 06:01 AM
тАО06-17-2002 06:01 AM
Re: AWK , uid and NIS
live free or die
harry