0
我正在检查苹果机器上的XProtect文件是否是最新的。我已经找到了方法,以检查包含此信息的本地.plist在其网站上的.plist。但是,如果当前日期在Apple在线上发布最新.plist的最后30天内,我们现在希望允许用户继续使用。我试图弄清楚如何将在线发布的日期与当地时间进行比较,如果在线版本在最近30天内允许脚本继续。检查一个网站上的文件是否在过去30天内
curl -sL http://google.com -o /dev/null
if [[ $? == 0 ]]; then
URL=http://configuration.apple.com/configurations/macosx/xprotect/3/clientConfiguration.plist
curl -s $URL | awk '/\<\?xml/{i++}i' > /tmp/meta.plist
urlresult=$(/usr/libexec/PlistBuddy -c "Print :meta:Version" "/tmp/meta.plist")
locresult=$(defaults read /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/XProtect.meta Version)
if [ find /tmp/meta.plist -mtime -30 ]; then
xpresult="Within 30 days"
else
if [ "$urlresult" == "$locresult" ]; then
xpresult="Up to date"
else
xpresult="out of date"
fi
fi
fi
谢谢。
这样比较部分正确地谢谢你,但是有没有办法让我查看文件的'$ URL'来比较它?当我尝试它告诉我,该文件无法找到? – Mojoscream
我不跟随抱歉。你能详细说明吗? – konsolebox
当然,我实际上正在查看过去30天内变量“URL”上发布的信息是否已更新。所以我想看看位于'http:// configuration.apple.com/configurations/macosx/xprotect/3/clientConfiguration.plist'的文件是否从当天起30天或更短时间发布。 – Mojoscream