The UNIX and Linux Forums  


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




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 09-23-2008
aliahsan81 aliahsan81 is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 62
Thanks for reply,Not working means when i pass one value in loop to Variable $confd,I don't process it instead it consider online with all the document root.I show you my code,and if i run staticelly using /var/www/html output is fine but when i put
in loop problem occourced.I show you output for both.



Code:
#!/bin/bash
let test=0

abc="/var/www/html"
docroot=$(grep -H DocumentRoot /etc/httpd/conf.d/*.conf | awk -F' ' '{ print $3 }'| sort -u | uniq)
doccount=$(grep -H DocumentRoot /etc/httpd/conf.d/*.conf | awk -F' ' '{ print $3 }'| sort -u | uniq | wc -l)
#i=0
#while [ $i -le $doccount ]
# do
#    confd="$docroot\n"
#echo $confd
    find $abc -type d -perm /o=w | while read DIR
    do

    test=$(cd "$DIR"; ls -A *.html *.php  2>/dev/null | wc -l)

        if [ "$test" != "0" ]
                   then


            echo "DIR Found WITH FILES"$DIR $test
           fi


        if [ `ls -a "$DIR" | wc -l` -le 2 ]
    
                   then

            echo "Writable_dir Empty"$DIR
            fi


    done
#i=$(( $i + 1 ))
#done


        count=$(find /var/www/html/ -type f -perm /o=w | grep -i ".htaccess"| wc -l )

        find "$abc" -type f -perm /o=w | grep -i ".htaccess" | awk  -F. '{ print $1 }' | while read this

        do
        echo "_htaccess_is_Writable"$this
        done
 
Output with static docroot

DIR Found WITH FILES/var/www/html/test3 4
DIR Found WITH FILES/var/www/html/test3/abc 2
Writable_dir Empty/var/www/html/abc
DIR Found WITH FILES/var/www/html/test/abc 1
DIR Found WITH FILES/var/www/html/test2 1


Output with duynamic Docroot


"/var/www/html" "/var/www/test/www.example.com" "/var/www/www.example.com"\n
find: "/var/www: No such file or directory
find: "/var/www/test: No such file or directory
find: "/var/www: No such file or directory
"/var/www/html" "/var/www/test/www.example.com" "/var/www/www.example.com"\n
find: "/var/www: No such file or directory
find: "/var/www/test: No such file or directory