检查整个目录php语法错误脚本

其实也可以检查其他语言的语法错误,把代码内的php -l 换了就行

公司主营业务:网站建设、成都做网站、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联推出新安免费做网站回馈大家。

#! /bin/bash
#
# check_php_syntax.sh
# Copyright (C) 2014 
#
# Distributed under terms of the MIT license.
#


#!/bin/bash
# check php syntax 
if [ $# -lt 1 ];then
    echo 'Usage: ' $0  'directory';
    exit
fi
if [ ! -d $1 ];then
    echo $1  'not a directory,please check!';
    exit
fi
directory=$1
echo $directory
temp_file="/tmp/file$$"
echo $temp_file

ls -R $directory | awk  '
BEGIN{
FS="n"    
folder="'$directory'"
logname="'$temp_file'"
temp=""
}

{
    if($0~/.php$/){
        system("php -l " folder "/" $0  "   >>  " logname  " 2>&1")  
    }
    if($0~/:$/){
        temp=substr($0,1,length($0)-1)
        folder=temp
    }
}
'
#folder=substr($1,1,length($1)-1)
if [ -e $temp_file ];then
    cat $temp_file | awk '
    BEGIN{
    error = 0
}
{
    if($0~/Parse/) {
        error++ 
        errorfile[$0] = $0
    }   
}
END{
print "错误文件:" error "个"
if(length(errorfile)>0) print "错误行数:"
    for (i in errorfile)
        print i
    }
    '
else
    echo "php file not found."
    exit;
fi

标题名称:检查整个目录php语法错误脚本
当前路径:http://bzwzjz.com/article/geppdo.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 四川成都网站制作 手机网站制作 成都网站建设公司 广安网站设计 网站制作 外贸网站建设 网站建设 成都网站制作 成都网站设计 自适应网站设计 成都网站建设公司 网站设计 高端网站设计 专业网站建设 定制网站建设 成都网站制作 成都网站设计 重庆网站建设 公司网站建设 成都网站建设公司 成都网站建设 成都网站制作