Here's a quick bash script that I wrote to add adsense code just before the closing body tag in several accounts with the same file name. Could be modified to take the file names as the last argument if different.
Note: replace the UA-####### with your particular ID number assigned by adsense.
#!/bin/bash
# insert_adsense.sh
# usage: ./insert_adsense.sh {account} {count}
ACCOUNT=$1
COUNT=$2
FILE=/home/${ACCOUNT}/public _html/index.inc.php
ADSENSE="
<script src=\"http://www.google-a nalytics.com/urchin.js\" type=\"text/javascript\&q uot;>
</script>
<script type=\"text/javascript\&q uot;>
_uacct = \"UA-#######-${COUNT}\&qu ot;;
urchinTracker();
</script>
"
cp $FILE $FILE.bak
replace "</body>" "${ADSENSE}</body>& quot; -- $FILE
exit 0
- sandip's blog
- Login or register to post comments