simple diff script
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > simple diff script




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    simple diff script  
mac8500


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-11-06 02:59 PM

I'm looking for a simple shell script that would compare uid et gid
files on a bunch of servers (solaris, aix) from a white list.  Looking
for a local solution as no nis, ldap, nis+ running.

I tought of using a diff -f and toy with the output (as it gives the ed
help lines). But there as to be a simpler way.

I also tought of using a single cmp line and mail myself the results
(server x, y, z are not identical) but i'm pretty much interested in
the output.

White list

root:0
test:89
user1:88
user2:89
user3:90

server x /etc/passwd

root:0
test:88
user1:88
user2:90
user3:91

Would report in a temp file user2, user3 on server x is different.

I know some sysadmins used that before 






[ Post a follow-up to this message ]



    Re: simple diff script  
Chris F.A. Johnson


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-27-06 12:55 PM

On 2006-04-10, mac8500 wrote:
> I'm looking for a simple shell script that would compare uid et gid
> files on a bunch of servers (solaris, aix) from a white list.  Looking
> for a local solution as no nis, ldap, nis+ running.
>
> I tought of using a diff -f and toy with the output (as it gives the ed
> help lines). But there as to be a simpler way.
>
> I also tought of using a single cmp line and mail myself the results
> (server x, y, z are not identical) but i'm pretty much interested in
> the output.
>
> White list
>
> root:0
> test:89
> user1:88
> user2:89
> user3:90
>
> server x /etc/passwd
>
> root:0
> test:88
> user1:88
> user2:90
> user3:91
>
> Would report in a temp file user2, user3 on server x is different.
>
> I know some sysadmins used that before 

If whitelist just contains fields 1 and 3 from /etc/passwd:

awk -F: 'FILENAME == "whitelist" { u[$1,$2]++; next }
u[$1,$3] == 0 { print $1 ":" $3 }' whitelist /etc/passwd

If it contains the entire passwd file:

awk -F: 'FILENAME == "whitelist" { u[$1,$3]++; next }
u[$1,$3] == 0 { print $1 ":" $3 }' whitelist /etc/passwd

--
Chris F.A. Johnson, author   |    <http://cfaj.freeshell.org>
Shell Scripting Recipes:     |  My code in this post, if any,
A Problem-Solution Approach  |          is released under the
2005, Apress                 |     GNU General Public Licence





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 08:27 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register