1753701 Members
4841 Online
108799 Solutions
New Discussion юеВ

Need a Script help

 
SOLVED
Go to solution
George Abraham_3
Occasional Advisor

Need a Script help

Hello Gurus,

I inherited a script that runs on all the unix servers. It checks for suid changes and sends a report.

Now on AIX servers i want to EXCLUDE the /proc directory.

So if the server is AIX exclude /Proc.

Can you please suggest what modification needs to be done?..Attached is the existing script

Any help will be welcome

regards
George
12 REPLIES 12
Pete Randall
Outstanding Contributor

Re: Need a Script help

Change the find command. It starts with /:

find /

Change it to a list of all the mounted file systems except /Proc:

find /usr /etc /home /var

and so on.


Pete

Pete
George Abraham_3
Occasional Advisor

Re: Need a Script help


I would like to check if OS=AIX then just exclude /proc.

thanks
George
Pat Lieberg
Valued Contributor

Re: Need a Script help

You could do a condition handler that determines which set of directories to work against based on the output of a uname -a. You could use an if/then or possibly a case statement.

No time for coding examples right now. If I get time later, I can work on it. Someone else will probably have an example for you though.
Mel Burslan
Honored Contributor

Re: Need a Script help

OSTYPE=$(uname -s)

this will give you HPUX output (in capital letters) if executed on an hpux system. Run it on AIX machine and see what it generates and construct an "if" logic around the strings after your case statement block is executed.
________________________________
UNIX because I majored in cryptology...
Alan Meyer_4
Respected Contributor

Re: Need a Script help

in your find command lind before you |sort, yoyu could do a |grep -v '^/proc/' That would remove all files and directories under the /proc filesystem
" I may not be certified, but I am certifiable... "
Mel Burslan
Honored Contributor

Re: Need a Script help

I just remembered that I had an old, junky AIX box in one corner of mydata center and the command's output is AIX in capital letters as well.
________________________________
UNIX because I majored in cryptology...
Alan Meyer_4
Respected Contributor

Re: Need a Script help

use my above grep suggestion in conjunction with the other commanets about determining the OS = AIX
" I may not be certified, but I am certifiable... "
James R. Ferguson
Acclaimed Contributor

Re: Need a Script help

Hi George:

Use find()s '-prune'. Consider a case where you would want to find all files named "core*" [without being careful of what was returned :-)) ] and want to do that from the root directory, for every mountpoint there under, *except* /usr.

This syntax works on HP-UX or AIX so you can adapt it to your needs. In fact, since HP-UX doesn't have a /proc directory you can probably unconditionally factor this into your 'find' command regardless of the OS.

By example:

# find / -name usr -prune -o \( -type f -a -name "core*" -a -print \)

...this returns all files named "core*" from all directories *except* 'usr'.

Regards!

...JRF...
J. Callender
Frequent Advisor
Solution

Re: Need a Script help

George,

You could try the following.

NOTE: I don't have AIX machine. was not tested.

##################################################################################################
find_all_suid_FILES()
{
OSTYPE=`uname -s`
if [ ${OSTYPE} = "HP-UX" -o ${OSTYPE} = "AIX" ]
then
find / -type f -a \( -perm -u+s -o -perm -g+s \) -exec ls -dl {} \; | \
sort -k 3,3 -k 9,9 -k 4,4 > ${WORK_FILE} # Sort by user, group, and file
elif [ ${OSTYPE} = "AIX" ]
then
find / -type f -a \( -perm -u+s -o -perm -g+s \) -exec ls -dl {} \; | \
sort -k 3,3 -k 9,9 -k 4,4 | grep -v /proc > ${WORK_FILE} # Sort by user, group, and file
fi
}
#################################################################################################

-Junior