帮我写个SHELL脚本命令:usrbincthsSecScan grep -A 50 cthsSecScan 100-235 Resultsgrep -ci Great no warnings 如果返回为0则向企业微信机器人发送一条信息并判断机器有没有外网。
#!/bin/bash
result=$(/usr/bin/cthsSecScan | grep -A 50 "cthsSecScan 1.0.0-235 Results" | grep -ci "Great, no warnings")
if [ $result -eq 0 ]; then
ping -c 1 www.baidu.com > /dev/null
if [ $? -eq 0 ]; then
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_KEY'
-H 'Content-Type: application/json'
-d '{
"msgtype": "text",
"text": {
"content": "cthsSecScan has warnings!"
}
}'
else
echo "No internet connection!"
fi
else
echo "No warnings found!"
fi
注意:需要将YOUR_KEY替换为企业微信机器人的Webhook地址的key。
原文地址: https://www.cveoy.top/t/topic/bGe1 著作权归作者所有。请勿转载和采集!