
Dmitryilyin
|
Posted - 2008.11.21 12:33:00 -
[1]
I use this primitive script to monitor what skill is training, how long is left and when training will finish.
====cut=====
#!/bin/sh
GetDefaults() { USERID="?" APIKEY="?" CHARID="?" #FILL ABOVE FIELDS PAGE="http://api.eve-online.com" }
Query() { curl "${PAGE}${1}" --data "userID=${USERID}" --data "apikey=${APIKEY}" --data "characterID=${CHARID}" 2>/dev/null }
SkillTraining() { ans=`Query "/char/SkillInTraining.xml.aspx"` tree=`Query "/eve/SkillTree.xml.aspx"` bit=`echo -e "${ans}" | grep '<skillInTraining>' | awk -F '>' '{ print $2 }' | awk -F '<' '{ print $1 }'` skillid=`echo -e "${ans}" | grep '<trainingTypeID>' | awk -F '>' '{ print $2 }' | awk -F '<' '{ print $1 }'` skillname=`echo -e "${tree}" | grep -e ".*typeName.*typeID=\"${skillid}\"" | awk -F "\"" '{print $2}'` tolevel=`echo -e "${ans}" | grep '<trainingToLevel>' | awk -F '>' '{ print $2 }' | awk -F '<' '{ print $1 }'` curtime=`echo -e "${ans}" | grep '<currentTQTime' | awk -F '>' '{ print $2 }' | awk -F '<' '{ print $1 }'` endtime=`echo -e "${ans}" | grep '<trainingEndTime>' | awk -F '>' '{ print $2 }' | awk -F '<' '{ print $1 }'` localtime=`date +%Y" "%m" "%d" "%H" "%M" "%S` #echo "$ans" if [ "${bit}" = "0" ]; then { echo "Not training!" exit 1 } else { echo "Training: ${skillname} ${tolevel} " awk -v curtime="${curtime}" -v endtime="${endtime}" -v localtime="${localtime}" ' BEGIN { gsub(/-/, " ", curtime) gsub(/:/, " ", curtime) cts=mktime(curtime) #EVE current time gsub(/-/, " ", endtime) gsub(/:/, " ", endtime) ets=mktime(endtime) #EVE end time gsub(/-/, " ", starttime) gsub(/:/, " ", starttime) lts=mktime(localtime) #local time diff=ets-cts #Time left lets=lts+diff #Local end time days=int(diff/60/60/24) diff=diff-(days*24*60*60) hours=int(diff/60/60) diff=diff-(hours*60*60) minutes=int(diff/60) diff=diff-(minutes*60) seconds=diff printf("Time left: "days" days, "hours" hours, "minutes" minutes, "seconds" seconds\n") printf("Will finish at: "strftime("%Y-%m-%d %H:%M:%S",lets)"\n") } ' exit 0 } fi }
GetDefaults SkillTraining
=====cut===== Example: > sh skilltraining.sh Training: Gunnery 4 Time left: 1 days, 1 hours, 42 minutes, 33 seconds Will finish at: 2008-11-22 16:39:40
|