linux - 检查域是否在服务器上处于事件状态

标签 linux bash cpanel whm

我正在尝试检查域是否在服务器上处于事件状态。到目前为止,我得到了错误。

list=/root/domainlist.txt
for i in $(cat $list)
do
  echo "checking " $i
  $ip = host $i |grep -o -m 100 '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'
  if [[ $ip == "xx.xx.xx.xx" ]]; then
    $i >> /root/activedomains.txt
  fi
done

输出:

activedomains: line 4: =: command not found

这是我得到的当前错误。

最佳答案

  • =
  • 前后没有空格
  • 作业中没有美元符号
  • 您可能需要命令的结果,因此将其包含在 $( )

    ip=$(host $i |grep -o -m 100 '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}')
    

像这样写入文件

echo "$i" >> /root/activedomains.txt

关于linux - 检查域是否在服务器上处于事件状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15142343/

相关文章:

linux - 如何用linux最快的方式发送邮件

linux - 从文件中的 VMSTAT 中提取 %CPU 使用率

mysql - Cpanel MySQL 远程创建/删除数据库

linux - 服务器加载时间问题

email - CNAME 和 WHM - 如何停止自动附加域名

python - Vagrant w/windows 作为主机,由于 crlf,文件不在 vm 上运行

linux - 如何在 Linux 上按名称而不是 PID 杀死进程?

python - 如何从一个文件中获取在另一个文件中包含字符串的所有行?

bash - 带换行符的 Grep 搜索字符串

bash - 存储在变量中的赋值语句导致在 Bash 中找不到命令错误