Please help with Kshell Script!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Please help with Kshell Script!
# 1  
Old 12-14-2011
Please help with Kshell Script!

I am an AIX noobie, and have a question around an AIX 5.2 script that I need to run. Security Audit requires us to have no World Writable files on our server, but every time we restart the Domino server on AIX it re-flags two files as World Writable.

I have a little script that I created that works to fix this, but I want to make it so that I can use the same exact script on all of our Domino servers. Here is what I have:
Code:
#!/bin/ksh
 
cd $HOME/data/nsd.sl04 <- This needs to be changed to nsd.serverID
chmod 664 nsd*

Domino puts the files in an nsd.xxxx directory where the xxxx is the userID of the server.

Please let me know if there is an easy way of doing this. I was going to try to use $UserID in the second line but could not get it to work.

Thanks!


Moderator's Comments:
Mod Comment How to use code tags

Last edited by Franklin52; 12-15-2011 at 03:21 AM.. Reason: Please use code tags for code and data samples, thank you
# 2  
Old 12-14-2011
If server ID is the hostname you can use something like serverID=$(uname -n).
# 3  
Old 12-14-2011
I believe all home dirs are the next to last field in /etc/passwd, unless you have network accounts, then 'ypcat passwd', 'niscat passwd' or the like. You might just say "chmod -R o-w /" but that takes a while. Are the domino files always just "$HOME/data/nsd.*/nsd*"?
# 4  
Old 12-14-2011
Reply..

Yes, they are always in the nsd.* directory and start with nsd. Is there a way in the chmod command to use the wildcards to do anything under an nsd.* directory that starts with nsd*?

Thanks so much for your replies.
# 5  
Old 12-14-2011
Sure, wild cards would be fine. For all users in /home1, /home2/ etc., you could just
Code:
chmod /home*/data/nsd.*/nsd* 2>/dev/null

(The shell expands it all and chmod just has a long argument list.) Of course, if you want to just touch the ones that need to be fixed, and avoid errors if no such file
Code:
ls -ltd /home*/data/nsd.*/nsd* 2>/dev/null | sed -n '
    s/^-.......w.*//p
  ' | xargs -0 chmod o-w

You might want to patrol all and fix all and report, on a cron:
Code:
#!/bin/ksh

date "+%Y-%m-%d %H:%M:%S ($$) WWList scan start."

find / -type f -ls | sed -n '
    s/.* -.......w. .* \//\//p
  ' | tee /tmp/WWlist.$$ | xargs -0 chmod o-w

if [ -s /tmp/WWlist.$$ ]
then
 echo "WWList not empty: "$(wc -l </tmp/WWlist.$$)
 mail -s $(uname -n)-WWList your_email </tmp/WWlist.$$
else
  rm /tmp/WWlist.$$
fi

date "+%Y-%m-%d %H:%M:%S ($$) WWList scan end."


Last edited by DGPickett; 12-14-2011 at 04:55 PM..
# 6  
Old 12-14-2011
Check the man page for chmod - most implementations support a recursive option.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

AIX UNIX (kshell) to Linux Shell Script Migration.

Hi, Could you please let me know what kind of changes/issues commonly occurs at Scripting /command level during AIX Unix (kshell) to Linux shell script migration. (24 Replies)
Discussion started by: Raghuraman.R
24 Replies

2. UNIX for Dummies Questions & Answers

Passing variable to Alias in Hp kshell

Hi all, I have a series of directories which i open regularly. I want create an alias so that i can pass the direcotry name to alias and then this commands makes Cd to the path i need. COuld you please help on how to create an alias ex of what i am trying but couldn't succeeded #alias... (1 Reply)
Discussion started by: firestar
1 Replies

3. Shell Programming and Scripting

KShell regular expresion

Hi, I would like to know if the parameter i am passing to a shell script is contain the following charachter : ASM. I belive that i should use regular expresion here. Can one help ? Bellow is the "if statment" i need to fix with the reg exp: if ; then #echo "IT IS AN RDBMS... (4 Replies)
Discussion started by: yoavbe
4 Replies

4. Shell Programming and Scripting

How to see a variable value outside a function in kshell

Hi, I wrote a small shell script which had function C_fun() and script name is same C_fun.ksh Here is the program inside the script #!bin/ksh -x C_fun() { typeset TEXT=${1} } echo Value of TEXT $TEXT When Im running the above script with Parameter "R" as the option .... (6 Replies)
Discussion started by: somu_june
6 Replies

5. Shell Programming and Scripting

Substring operation in kshell

Hi, Please let me know how to perform the substring operation in kshell. If i have line like below 238923893282389034893489458945904589045454903490 i would like to retrieve the position 7 to 19, how to do this in kshell? (1 Reply)
Discussion started by: informsrini
1 Replies

6. Shell Programming and Scripting

running .sh script in kshell

hi i wrote a script in shell script(ChangeFiles.sh), now i need to run the script in korn shell. could anyone explain how to run the same script korn shell. thanks in advance Satya (2 Replies)
Discussion started by: Satyak
2 Replies

7. UNIX for Dummies Questions & Answers

Usage of fgrep -f command in kshell

Hi, Can I know the usage of fgrep -f command in kshell. Reqirement: Need to search for list of patterns in list of files and display all the files which are having atleast one in the patterns list. I hope fgrep -f will serve this purpose within a loop. But I am not successfull in doing this.... (0 Replies)
Discussion started by: divv
0 Replies

8. UNIX for Dummies Questions & Answers

kshell variables and awk

Hi, Is it possible to initialise a shell variable and set it to a value from an awk command? i.e. #set myvalue = to the first 8 charachters of the line that begins with 0 myvalue = awk '/^0/ {substr($0,1,8)}' myvaluefile or even declare a variable, then reinitialise it as part of the... (1 Reply)
Discussion started by: kshelluser
1 Replies

9. Shell Programming and Scripting

callint Kshell script from bash default shell

I am trying to set some environment variables in a shell script which is written in Kshell. I am invoking this script in .profile. The problem is envirnment variables are set within the script but after exiting the script those are gone. I don't have any problem with If I have Kshell as my default... (0 Replies)
Discussion started by: roopla
0 Replies

10. AIX

Kshell scripts and timing

Hello everyone, I have a script thats acting funky, what I would like to do is report to a file, how long its taking to get to certain area's, in seconds. For example. -- Start timer -- Run unix command 1 -- Run unix command 2 -- Stop timer -- Report Seconds -- etc etc Is there a way... (3 Replies)
Discussion started by: dbridle
3 Replies
Login or Register to Ask a Question