egrep -w 'TCP|UDP' ~/IPsDenied.txt | sed 's/:[^:]* in/ in/' | awk '{cmd="echo "$5" | geoIP | fgrep 'Country:' | cut -c 16-43"; cmd | getline rslt; close(cmd); print $1" "$2" "$3" "$4" "$5" "$6" "rslt}' >> ~/IPtoCountry.txt
为什么当我使用 launchd 或 cron 时,我的语句中的 geoIP 脚本没有被调用?它手动运行良好...我尝试将完整的 PATH 用于 geoIP 之类的~/geoIP
or./geoIP
或/Users/Admin/geoIP
#IPsDenied.txt
Apr 6 08:58:16 TCP 212.58.244.61:80 in
#IPtoCountry.txt
Apr 6 08:58:16 TCP 212.58.244.61 in United Kingdom
相反,我得到了
Apr 6 08:58:16 TCP 212.58.244.61