Pages: [1] :: one page |
|
Author |
Thread Statistics | Show CCP posts - 0 post(s) |
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
|
J nx
Glowing Goat
|
Posted - 2008.11.21 15:26:00 -
[2]
ah, nice.
i can use this for the fast checks when remote somewhere.
Thx for sharing
|
omgdutch2005
Gallente Advanced Planetary Exports Intergalactic Exports Group.
|
Posted - 2008.11.21 20:57:00 -
[3]
could this make a webpage orso?
i could run this (cron prefered, like every hour) and i can just check the site for my skill, while at work... (lotsa ports closed at my work...) even closed port 21 ^^ |
Dragonaire
Caldari Corax.
|
Posted - 2008.11.21 22:04:00 -
[4]
Should be able to redirect the output to a text file on your webserver and look at it like any other page on-line. Doesn't really need to be a webpage just something the browser can understand.
So something like
sh skilltraining.sh > my/web/server/root/mytextfile.txt
should work. You might need to run it through unix2dos to fix line ends if you have problems with how it displaying in windows. -- Finds camping stations from the inside much easier. Been known to write some PHP code for API from time to time too. |
Spurty
Caldari D00M. Triumvirate.
|
Posted - 2008.11.21 23:57:00 -
[5]
Edited by: Spurty on 22/11/2008 00:00:35 nice, but for my distro (Ubuntu 8.something), 'strftime' is not in awk, but rather 'gawk' so :
echo "Training: ${skillname} ${tolevel} " awk -v curtime="${curtime}" -v endtime="${endtime}" -v localtime="${localtime}" '
becomes
echo "Training: ${skillname} ${tolevel} " gawk -v curtime="${curtime}" -v endtime="${endtime}" -v localtime="${localtime}" '
$ ./eveshfun.sh Training: Amarr Titan 2 Time left: 5 days, 7 hours, 54 minutes, 58 seconds Will finish at: 2008-11-27 02:28:50
Kudos!
Man goes to the doc, with a strawberry growing out of his head. Doc says "I'll give you some cream to put on it." |
Dragonaire
Caldari Corax.
|
Posted - 2008.11.22 01:29:00 -
[6]
They should have gawk symlinked to awk but not first time I've found they can't get something right that all the other distros have for years No I'm not a fan of Ubuntu it always seems about as feature rich as Slackware from the 90s or Unix was last time I tried it in their default install. Yes I'm a OpenSuSE fan been using them since 5.x days -- Finds camping stations from the inside much easier. Been known to write some PHP code for API from time to time too. |
Dmitryilyin
|
Posted - 2008.11.22 13:14:00 -
[7]
Edited by: Dmitryilyin on 22/11/2008 13:15:00 One more tip: You can download /eve/SkillTree.xml.aspx to file curl http://api.eve-online.com/eve/SkillTree.xml.aspx > ~/eveskilltree.xml And change tree=`Query "/eve/SkillTree.xml.aspx"` to tree=`cat ~/eveskilltree.xml`
It will save from downloading skilltree every time.
If you want to run this by cron and log to file replace echo "Training: ${skillname} ${tolevel} " by echo -n "Training: ${skillname} ${tolevel} " To make output one string. cron commad: skilltraining.sh >> log.txt
It also returns 1 errorcode if nothing is training and 0 errcode if training something so you can skillraining.sh || mail [email protected] -s "Training finished!"
Or you can write this function inside script or do something more sofisticated. In UNIX you are limited only by your skills and imagination!
|
Dragonaire
Caldari Corax.
|
Posted - 2008.11.23 01:12:00 -
[8]
Point of unix2dos and dos2unix is to change the line ends but sed can do it just as well and might even be faster not that you'll notice the difference either way Great thing about Linux is there's more then one way to do it and that you can do almost anything by just stringing some simple tools together. -- Finds camping stations from the inside much easier. Been known to write some PHP code for API from time to time too. |
Ulaa Aamula
Amarr
|
Posted - 2008.11.23 13:27:00 -
[9]
Thanks for this.
Works on FreeBSD 7.0 after installing gawk.
|
Dmitryilyin
|
Posted - 2008.11.24 09:22:00 -
[10]
Originally by: Ulaa Aamula Thanks for this.
Works on FreeBSD 7.0 after installing gawk.
Yes it's problem. BSD awk doesn't have lot of things GNU awk has. Actually all bsd baseutils has less features then gnu baseutils. The only exceptions is ifconfig which is much better in bsd.
|
|
Zhula Guixgrixks
Increasing Success by Lowering Expectations Vanguard.
|
Posted - 2008.11.24 11:22:00 -
[11]
ty
|
Ser Prius
|
Posted - 2008.11.25 19:47:00 -
[12]
What's next, an X-Window 3D Map Browser?
|
Flaming Candle
|
Posted - 2008.11.26 14:28:00 -
[13]
My Additions to the script, since I have multiple characters, I thought that changing the script each time to get the skill in training was a little like effort!
Originally by: Script
#!/bin/sh # # Based on the script found at: # http://oldforums.eveonline.com/?a=topic&threadID=929881 # Modified by Flaming Candle # # More advanced caching of the skill tree. # Now capable of handling multiple accounts. # Picks up the character name and displays it # # Uses an input file, where each line represents # a character and each line has the format: # <userid>,<apiKey>,<characterID> # #
GetDefaults() { USERID="" APIKEY="" CHARID="" #FILL ABOVE FIELDS PAGE="http://api.eve-online.com" TREE=`Query "/eve/SkillTree.xml.aspx"` }
Query() { curl "${PAGE}${1}" --data "userID=${USERID}" --data "apikey=${APIKEY}" --data "characterID=${CHARID}" 2>/dev/null }
SkillTraining() { char=`Query "/account/Characters.xml.aspx"` ans=`Query "/char/SkillInTraining.xml.aspx"`
charName=$(echo $char | grep "${CHARID}" | sed 's/.*name="\(.[^"]*\)" characterID="'${CHARID}'".*/\1/') 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"
echo "Character: ${charName}" 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") } ' } fi }
GetDefaults
# parse the input file. if [[ ! -a $1 ]]; then echo "please specify an input file as the first argument." exit 0 fi
cat $1 | while read LINE do USERID=$(echo $LINE | cut -d , -f 1); APIKEY=$(echo $LINE | cut -d , -f 2); CHARID=$(echo $LINE | cut -d , -f 3); SkillTraining; echo; done
|
|
|
|
Pages: [1] :: one page |
First page | Previous page | Next page | Last page |