#!/usr/bin/gawk -f # charities.cron 1.6.0 # (c) Stephen E. Sachs , 08/25/2001 # Released under GNU General Public License, www.gnu.org/copyleft/gpl.html # # This is a cron script in the gawk language to frequent the various # charity sites affiliated with freedonation.com. # # These sites have obtained corporate sponsorship to enable web users to # donate food, health care, and other goods to the needy by clicking on a # link. The sites generally count one click per IP address per # day; while it's hard for people to remember to return to each site each # day to donate, it's a perfect task for a cron job. This script uses # lynx to download the page to a temp file, identify the proper link, # "click" it (sending output to /dev/null), and then remove the temp file. # By making this a daily cron job, you can cause thousands of dollars to # be donated to charity each year. # # If you cannot run your own cron jobs, an alternative is to place the # command "./charities.cron &" in your .bashrc or .login file, so that the # script will execute each time you log in to your shell account and be # counted at least once each day. # # Please remember to change the line at the very beginning of this script # to reflect the location of gawk on your system (type 'which gawk' if # you're not sure), and do the same for lynx below. # # This version comments-out support for the charity sites affiliated with # greatergood.com and thehungersite.com, which are not currently # operational and will cause lynx to return errors. Should these sites # come back online, this support will be restored. The silver lining to # this change is that the current version avoids a tempfile security risk # created by the older code. # # Use in good health, # Steve BEGIN { # lynx is assumed to be /usr/bin/lynx lynxdump = "TERM=vt100 TMPDIR=/tmp /usr/bin/lynx -dump" # docharity("http://www.thehungersite.com","Donate Free Food") # docharity("http://www.thekidsaidssite.com","Donate Free Care") # docharity("http://www.therainforestsite.com","Donate") # docharity("http://www.thechildsurvivalsite.com","Donate Vitamin A") # docharity("http://www.thebreastcancersite.com","Donate Free Mammograms") # docharity("http://www.thelandminesite.com","Save Lives and Limbs") # freedonation.com uses static URLs freedonation[1] = "http://www.freedonation.com/aids/aids_thankyou.php3" freedonation[2] = "http://www.freedonation.com/arts/arts_thankyou.php3" freedonation[3] = "http://www.freedonation.com/cancer/cancer_thankyou.php3" freedonation[4] = "http://www.freedonation.com/children/children_thankyou.php3" freedonation[5] = "http://www.freedonation.com/edu/edu_thankyou.php3" freedonation[6] = "http://www.freedonation.com/envir/envir_thankyou.php3" freedonation[7] = "http://www.freedonation.com/homeless/homeless_thankyou.php3" freedonation[8] = "http://www.freedonation.com/hunger/hunger_thankyou.php3" for (i in freedonation) system(lynxdump" "freedonation[i]" >> /dev/null") } function docharity(x,y, tempfile, refnum, regexp1, regexp2, regexp3, address) { # x is the site address, 'http://foo.com' # y is the tag line that goes with the link, e.g. "Donate Free Food" tempfile = "/tmp/"systime()"charities.tmp" system(lynxdump" "x" >> "tempfile) regexp1 = "\[[0-9]+\]"y ; regexp2 ="[^\\[]*\\[|\\]|"y".*" while ((getline < tempfile) > 0) { if ($0 ~ regexp1) { gsub(regexp2,"",$0) ; refnum = $0 ; break } } regexp3 = refnum". http://" if (refnum) while ((getline < tempfile) > 0) { if ($0 ~ regexp3) { sub(".*http://","http://",$0) ; address = $0 ; break } } if (address) { gsub("'","",address); system(lynxdump" '"address"' >> /dev/null") } system("rm -f "tempfile) }