User Tools

Site Tools


unix:osx:firestats_sed

steps to modify a published iweb site (with all html files in the root tree at least):

  1. make a tmp dir like “rewrite”.
  2. run sed to add the firestats code.
  3. move files in rewrite to root dir and re-upload.

the code looks like

"<script type='text/javascript' src='http://benhall.com/firestats/js/fs.js.php?site_id=2'>" 

where siteid should be set correctly

modified for sed it looks like

"\<head\>\<script\ type=\'text\/javascript\'\ src=\'http\:\/\/benhall.com\/firestats\/js\/fs.js.php\?site_id=2\'\>\<\/script\>"

so the actual sed command should be similar to:

for file in *.html;do cat $file | sed -e s#\<head\>#\<head\>\<script\ type=\'text\/javascript\'\ src=\'http\:\/\/benhall.com\/firestats\/js\/fs.js.php\?site_id=2\'\>\<\/script\>#g >rewrite/$file;done

simple shell script “firesite.sh”:

#!/bin/bash
mkdir rewrite
for file in *.html;do cat $file | sed -e s#\<head\>#\<head\>\<script\ type=\'text\/javascript\'\ src=\'http\:\/\/benhall.com\/firestats\/js\/fs.js.php\?site_id=2\'\>\<\/script\>#g >rewrite/$file;done
cp rewrite/*.html .
unix/osx/firestats_sed.txt · Last modified: 2010/02/22 08:33 by ben