SuperTaoer::Thanksgiving

外天下、外物、外生、朝彻、见独、无古今、不死不生。

一月 8, 2008

linux shell脚本给特定的目录批量进行操作

文章类别: 程序 技术 — SuperTaoer @ 5:56 pm

因为服务器的cvs目录暴露在web目录下,通过 www.xxxxx.com/.cvs 就可以浏览到里面的内容,
传说中的及其的不安全。。。

无奈没有root权限,不能修改apache的httpd.conf

只得曲线救国,在每个.cvs目录下touch index.html
本来想手工做,无奈目录太多,还是批量一下儿吧。。。

  1. #!/bin/sh
  2.  
  3.  
  4. foreach_dir() {
  5.  
  6.     #for file in `./th.perl`
  7.     for file in $1/*
  8.     do
  9.  
  10.         if [ -d $file ]; then
  11.  
  12.             if echo $file | grep ".cvs" > /dev/null
  13.             then   
  14.  
  15.                 #echo "" > /dev/null
  16.                 echo "touch $file/index.html"
  17.                 touch $file/index.html
  18.             fi     
  19.  
  20.             foreach_dir $file
  21.         else   
  22.  
  23.             echo "" > /dev/null
  24.  
  25.         fi     
  26.     done   
  27. }
  28.  
  29. #foreach_dir $1
  30. #foreach_dir `find ./ -name .cvs* -type d`
  31.  
  32. for f in `find ./ -name .cvs* -type d`
  33. do
  34.  
  35.     echo "touch $f/index.html"
  36.     touch $f/index.html
  37.     foreach_dir $f
  38. done

这个伟大的脚本在今天下午下班前就这么tmd诞生了。。。

顺便说一下修改apache的方法。。。
就是找到 Options
类似 Options Indexes Includes FollowSymLinks MultiViews 这样儿的吧。。。
把其中的 Indexes 变成: -Indexes
Options -Indexes Includes FollowSymLinks MultiViews
就好了。。。
郁闷~~~还是能配置apache比较好。。。



Leave a Message

No Messages

No Messages

RSS feed for comments on this post. TrackBack URI

Leave a Message





本站使用 WordPress架设