Parse steamcmd output and extract buildid

buildid for public branch is under
depots.branches.public.buildid

The output from app_info_print is a line-oriented
json-like structure which is easily parsed by bash.
This commit is contained in:
Ben Peddell 2015-06-24 18:36:05 +10:00
parent 9ba4655315
commit b0936f2f13

View File

@ -96,11 +96,35 @@ function getCurrentVersion(){
}
#
# Parse the buildid from steamcmd
#
function parseSteamAppVer(){
local sname
while read name val; do
name="${name#\"}"
name="${name%\"}"
val="${val#\"}"
val="${val%\"}"
if [ "$name" = "}" ]; then
break
elif [ "$name" == "{" ]; then
parseSteamAppVer "${1}.${sname}"
else
if [ "$1" == ".depots.branches.public" -a "$name" == "buildid" ]; then
echo "$val"
break
fi
sname="${name}"
fi
done
}
#
# Get the current available server version on steamdb
#
function getAvailableVersion(){
bnumber=`$steamcmdroot/$steamcmdexec +login anonymous +app_info_print "$appid" +quit | grep -EA 5 "^\s+\"public\"$" | grep -E "^\s+\"buildid\"\s+" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -f3 | sed 's/^ //' | cut -c9-14`
bnumber=`$steamcmdroot/$steamcmdexec +login anonymous +app_info_print "$appid" +quit | while read name val; do if [ "${name}" == "{" ]; then parseSteamAppVer; break; fi; done`
return $bnumber
}