Take the following code and save it as "censusup.sh" (or any name of your choosing) in a convenient directory that you have full permissions to. I put it in my normal "downloads" directory, because I already have a symlink to my CensusPlus.lua file there, but someplace like your home directory would also be fine. Note that you should not put it somewhere in the WoW directory tree. Oh yes, don't forget to make the script executable (chmod +x censusup.sh)
Code: Select all
#!/bin/sh
myNAME=`basename $0`
cpNAME=**your username**
cpPW='**your password**'
echo "$myNAME: Checking for new version of CencusPlus.lua..."
# change PWD to where we are, for convenience
holdPWD=`pwd`
cd `dirname $0`
if ( [ CensusPlus.lua -nt CensusPlus.lua.gz ] );
then {
echo " lua file newer -- recompressing...";
gzip -c -9 CensusPlus.lua > CensusPlus.lua.gz;
lastERR=$?
if ( [ $lastERR -ne 0 ] );
then {
echo "$myNAME: Error from gzip: $lastERR"
};
else {
echo " ...compressed. Starting upload..."
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
curl -F [email protected] -F user=$cpNAME -F pw=$cpPW -w "\ncurl: transfered %{size_upload} bytes in %{time_total} seconds (%{speed_upload} b/s)\n" http://www.warcraftrealms.com/uniupload.php
lastERR=$?
echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
if ( [ $lastERR -ne 0 ] );
then {
echo "$myNAME: Error from curl: $lastERR"
};
else {
echo " upload successful."
};
fi
};
fi
};
else {
echo " compressed file up to date -- doing nothing.";
};
fi
cd $holdPWD
#eof
You will need to put your warcraftrealms.com username and password in the third and fourth lines. Keep the single quotes around the password, if you have any "special" characters in it.
Note that the script creates the gzip-compressed copy of the CensusPlus.lua file in the same directory as the script. It also assumes that the lua file (or a link to it) is also in the same directory. You can change this by hard-coding the path to the file in line 12, but I prefer having the symbolic link in the directory for convenience.
Note that I haven't spent a lot of time on this, so the error handling is rather simplistic (it just stops on errors), and it's fairly verbose. I also haven't gotten around to attempting to parse the response from the php script to look for logical errors. It just dumping out everything that's returned, so you need to look over the response to make sure that the "your name has been credited" line is there, and that no errors are reported.