Computing.Net > Forums > Unix > Unix script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Unix script

Reply to Message Icon

Name: ketan_java
Date: April 21, 2006 at 13:28:46 Pacific
OS: UNIX
CPU/Ram: P4
Product: Intel
Comment:

Hi all,

I need this script badly, could anyone please help me out for it? I tried toooo hard to write this but I don't find any proper solution for it.
Description:
To find world writable directories from one directory on network and log those directory names with full path to one log file.

I know there are some directories those are world-writable and need not to be logged in this log.

Following is more explanation:

Dir1 (this is the directory from where i want to find world writable directories)
Dir1.1
Dir1.2
Dir1.3
Dir1.4
Dir1.5

I know Dir1.2 is world-writable directory but about other directories I don't know. Now I need a script which finds world writable diretories from Dir1 and log the names of them in to Test.log but this list should not contain Dir1.2 (As I know it is world writable directory)

And at last, this script should send a mail to abc@def.com
Thanks in advance.

Regards,
Ketan



Sponsored Link
Ads by Google

Response Number 1
Name: ghostdog
Date: April 21, 2006 at 20:33:44 Pacific
Reply:

you can use the "find" command in unix. check the man page for its -perm option.


0

Response Number 2
Name: ketan_java
Date: April 24, 2006 at 11:57:32 Pacific
Reply:

Hi,

I tried with

find /dir1 -name -type d -print -perm -o+w >> /tmp/writabledirs.log
THEN..
grep "dir1.2" writabledirs.log | while read line ;
do
#echo "$line"
if "$line" == "/dir1/dir1.2"
else
grep "$line" -v writabledirs.log > newwritabledirs.log
done

This do...done is to search dir1.2 and not log that directory name in another log.

Also I tried with:

find /dir1 -type d -print -perm 777 >> /tmp/writabledirs.log
mail -s "World Writable Directory(ies) found..." abc@def.com root < /tmp/writabledirs.log

Then I tried with:
find /dir1 \( -local -o -prune \) -perm -2 \!
\( -type d \) -ls >> /tmp/writabledirs.log
mail -s "World Writable Directory(ies) found..." abc@def.com root < /tmp/writabledirs.log


But any of them does not work, it shows all the directories with any permission!! Could you please help me to find proper solution ASAP?

Thanks in advance.

Regards,
Ketan


0

Response Number 3
Name: ketan_java
Date: May 8, 2006 at 17:51:30 Pacific
Reply:

Please help me to write such script. I am badly requires this script.

Thanks in advance.

Regards,
Ketan


0

Response Number 4
Name: Grino
Date: June 21, 2006 at 17:14:06 Pacific
Reply:

Try this example and then add your "-path DIR -prune -o" sequence or if you are only interested in a top level directory use "-maxdepth 1" so that it doesn't travel down into sub-directories like Dir1.2 or Dir1.3.

find / -noleaf -path /proc -prune -o -path /export -prune -o -perm -002 \( -type f \) -ls

OR

find . -maxdepth 1 -perm -002 \( -type f \) -ls


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Unix script

Unix Script ignoring cmd line vars www.computing.net/answers/unix/unix-script-ignoring-cmd-line-vars/6193.html

Run a Unix Script from VB or ASP www.computing.net/answers/unix/run-a-unix-script-from-vb-or-asp-/4384.html

help redoing unix script student db www.computing.net/answers/unix/help-redoing-unix-script-student-db/5151.html