The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
finding difficult to check a condition megh SUN Solaris 1 11-07-2008 09:48 AM
Linux shell Script not null checking IF condition kaushys UNIX for Dummies Questions & Answers 3 07-02-2008 06:54 AM
Shell script - If---fi condition yog_chavan Shell Programming and Scripting 4 05-07-2008 10:46 AM
script to check for a condition inside a file kiran1112 Shell Programming and Scripting 11 03-21-2007 09:38 AM
need help with test condition in shell script pieman8080 Shell Programming and Scripting 9 09-11-2006 06:20 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-20-2009
sakthilinux sakthilinux is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 11
Smile Help with shell script to check the condition.


Hi,

I want to script for this scenerio,

OSR Settings

Scenario : We are looking to find all the *.a files from the following locations in the filesystem of a server.

OSR Directories

/etc
/bin
/usr/bin
/usr/sbin
/var/adm

These *.a files should have the permissions on 'Other' as r-x or more stringent.
The script should display only those *.a files which have full permissions (rwx) on their 'Other'.

Also , the *.a files must be owned , only by one of the following userids and groupids:

System UserIds

root ,daemon,bin,sys,adm,uucp,nuucp,lpd,imnadm,ipsec,ldap,lp,snapp,invscout

System GroupIds

system,security,bin,sys,adm,uucp,mail,printq,cron,audit,shutdown,ecs,imnadm,ipsec,ldap,lp,haemrm,sna pp,hacmp

The script should display all *.a files that are not owned by any one of the above listed system userids and groupids


Could you please help me anyone?

Thanks in advance…

Regards,
Shakthi
  #2 (permalink)  
Old 03-20-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,311
Moving this to the shell scripting area.
  #3 (permalink)  
Old 03-20-2009
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,419
this might help you

Code:
ls -l *.a|awk '{k=0;for(i=6;i<=8;i++)k+=((substr($1,i+2,1)~/[rwxs]/)*2^(8-i));if(k==7){printf(" %0o ",k);print $9;}}'

  #4 (permalink)  
Old 03-20-2009
pludi's Avatar
pludi pludi is online now Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,957
Quote:
Originally Posted by sakthilinux View Post
[...]Also , the *.a files must be owned , only by one of the following userids and groupids
[...]
The script should display all *.a files that are not owned by any one of the above listed system userids and groupids[...]
Which one is it? Display those owned by the listed UIDs/GIDs or omit those?
  #5 (permalink)  
Old 03-20-2009
sakthilinux sakthilinux is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 11
omit those..
  #6 (permalink)  
Old 03-20-2009
sakthilinux sakthilinux is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 11
any idea?
  #7 (permalink)  
Old 03-20-2009
pludi's Avatar
pludi pludi is online now Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,957

Code:
$ find /etc /bin /usr/bin /usr/sbin /var/adm \
-name '*.a' \
'!' '(' -user root -o -user daemon -o -user bin -o -user sys ')' \
'!' '(' system -o -group security -o -group bin -o -group sys ')' \
-ls | awk '$3~/[r-]-[x-]$/{print $11}'

Add additional users/groups as needed
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:09 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0