0
我已經創建了一個bash腳本,它通過一個crontab運行,該腳本檢查linux主機上安裝的nmap版本。問題是,由於某種原因,檢查工作不正常,它總是試圖一次又一次地安裝NMAP ...檢查程序的版本,所以在bash中的東西
#!/bin/sh
if ! $(nmap --version | grep -q "7.12"); then
wget https://nmap.org/dist/nmap-7.12.tar.bz2 -P /tmp/
cd /tmp && bzip2 -cd nmap-7.12.tar.bz2 | tar xvf -
cd nmap-7.12
./configure --without-zenmap
make
make install
cd ..
rm nmap-7.12.tar.bz2
rm -rf nmap-7.12
reboot
fi
如果我檢查,看看是否作業運行(這是它應該一次,但從來沒有一次因爲版本應與第二次)這是...
$> ps aux | grep nmap
root 27696 15.4 0.3 2940 1464 ? R 16:31 0:00 /bin/bash ./configure --disable-option-checking --prefix=/usr/local --without-zenmap --cache-file=/dev/null --srcdir=. --no-create --no-recursion
運行命令行收益率檢查(無-q):
$> nmap --version | grep "7.12"
Nmap version 7.12 (https://nmap.org)
什麼是搞砸了我的腳本PT?