Also, this version has a few more greps as I have to keep grep'ing until I get to the specific values I want. If you know a better way to get specific subsets of matches in a bash script, then please post it.
someone somewhere over the rainbow asked for a cronable voting script. I just wanted to see if I could do it and here is my crappy version.
Please note that each of the commands should be on one line, they shouldn't be split in to two lines like they are here. If there is a full line break then that signifies two seperate lines. If there is two lines with no space between, then those should be on one line. You must have version 1.9.1 or higher of wget or else the --post-data option isn't available. This could also be turned into a neater looking perl script.
Code: Select all
#/bin/sh
wget -O ~/rank.html http://www.topmudsites.com/cgi-bin/topmuds/rankem.cgi?id=idles
ssid1=`grep -io '"ssid1" value=".*"' ~/rank.html | grep -io 'value=".*"' | grep -io '".*"' | grep -io '[a-zA-Z0-9]\+'`
mudid=`grep -io '"mudid" value=".*"' ~/rank.html | grep -io '[0-9]\+'`
do=`grep -io '"do" value=".*"' ~/rank.html | grep -io 'value=".*"' | grep -io '".*"' | grep -io '[a-zA-Z]\+'`
submit=`grep -io '"submit" value=".*"' ~/rank.html | grep -io 'value=".*"' | grep -io '".*"' | grep -io '[a-zA-Z]\+'`
rm rank.html
wget -O ~/answer.html --post-data=\"mudid=$mudid\&ssid1=$ssid1\&do=$do\&submit=$submit\" http://www.topmudsites.com/vote.php