基线脚本执行时报perl: command not found

现象

某次基线安全检查,执行脚本是,报错:
86c221be-6ab2-ef53-1589-fe16877914f4.sh: line 32: perl: command not found
环境:CentOS Linux release 7.4.1708 (Core)

原因:

脚本内容如下:

#!/bin/sh
[ $# -ne 2 ] && { 
 echo "Usage: sh 86c221be-6ab2-ef53-1589-fe16877914f4.sh  <SU用户(SU或高权限用户)> <SU密码>";
 exit 1;
}
# 获取当前路径

pathname=`pwd`


echo "touch /tmp/nsfocus_mod_tmp;">/tmp/NSF{nsf_tm}_nsfocus_grub_tmp
echo "chmod 777 /tmp/nsfocus_mod_tmp;">>/tmp/NSF{nsf_tm}_nsfocus_grub_tmp
echo "if [ -f \"/etc/grub.conf\" ];then">>/tmp/NSF{nsf_tm}_nsfocus_grub_tmp
echo "    grub_mod=\`ls -l /etc/grub.conf | grep 'l[r-][w-][x-]'\`;">>/tmp/NSF{nsf_tm}_nsfocus_grub_tmp
echo "    if [ -z \"\$grub_mod\" ];then">>/tmp/NSF{nsf_tm}_nsfocus_grub_tmp
echo "        grub_mod=\`ls -l /etc/grub.conf\`;">>/tmp/NSF{nsf_tm}_nsfocus_grub_tmp
echo "        chmod --reference=/etc/grub.conf /tmp/nsfocus_mod_tmp;">>/tmp/NSF{nsf_tm}_nsfocus_grub_tmp
echo "    else">>/tmp/NSF{nsf_tm}_nsfocus_grub_tmp
echo "        grub_mod=\`ls -l /boot/grub/grub.conf\`;">>/tmp/NSF{nsf_tm}_nsfocus_grub_tmp
echo "        chmod --reference=/boot/grub/grub.conf /tmp/nsfocus_mod_tmp;">>/tmp/NSF{nsf_tm}_nsfocus_grub_tmp
echo "    fi">>/tmp/NSF{nsf_tm}_nsfocus_grub_tmp
echo "elif [ -f \"/boot/grub/grub.conf\" ];then">>/tmp/NSF{nsf_tm}_nsfocus_grub_tmp
echo "    grub_mod=\`ls -l /boot/grub/grub.conf\`;">>/tmp/NSF{nsf_tm}_nsfocus_grub_tmp
echo "    chmod --reference=/boot/grub/grub.conf /tmp/nsfocus_mod_tmp;">>/tmp/NSF{nsf_tm}_nsfocus_grub_tmp
echo "elif [ -f \"/etc/lilo.conf\" ];then">>/tmp/NSF{nsf_tm}_nsfocus_grub_tmp
echo "    grub_mod=\`ls -l /etc/lilo.conf\`;">>/tmp/NSF{nsf_tm}_nsfocus_grub_tmp
echo "    chmod --reference=/etc/lilo.conf /tmp/nsfocus_mod_tmp;">>/tmp/NSF{nsf_tm}_nsfocus_grub_tmp
echo "fi">>/tmp/NSF{nsf_tm}_nsfocus_grub_tmp
sh /tmp/NSF{nsf_tm}_nsfocus_grub_tmp

# 执行pl脚本
perl $pathname/86c221be-6ab2-ef53-1589-fe16877914f4.pl "${1}" "${2}"

可知环境中没有perl解释器,故报上述错误,安装即可。

处理:

yum -y install perl perl-devel
其中,perl-devel是perl开发环境依赖包,linux中,很多*-devel结尾都是相关环境的开发包,其内主要包括一些头文件和静态链接库。
在这里插入图片描述
再次执行成功:
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/ximenjianxue/article/details/107260568