# ### olinkxml.sh ### ### Usage: ### ### olinkxml.sh linkdir url phrase ### ### Create link to public website where phrase is in files found under linkdir. ### ### if [ "$3" = "" ] then echo "Usage: $0 linkdir url phrase" exit 1 fi linkdir=$1 url=$2 key1=$3 key2=$4 key3=$5 key4=$6 key5=$7 key6=$8 key7=$9 ### Build phrase phrase=$key1 if [ "$key2" != "" ] then phrase="${key1} ${key2}" fi if [ "$key3" != "" ] then phrase="${key1} ${key2} ${key3}" fi if [ "$key4" != "" ] then phrase="${key1} ${key2} ${key3} ${key4}" fi if [ "$key5" != "" ] then phrase="${key1} ${key2} ${key3} ${key4} ${key5}" fi if [ "$key6" != "" ] then phrase="${key1} ${key2} ${key3} ${key4} ${key5} ${key6}" fi if [ "$key7" != "" ] then phrase="${key1} ${key2} ${key3} ${key4} ${key5} ${key6} ${key7}" fi if [ "$linkdir" = "" ] then echo "Must enter link directory" exit 1 fi ### ### Look in link directory for files that have match ### for i in `find $linkdir -name \*.xml.html -print` do echo $i if `grep -w "$grep" $i >/dev/null 2>/dev/null` then atag=`/usr/local/bin/atag.sh $i $grep` if `echo $atag | grep 1 >/dev/null 2>/dev/null` then echo "disqualified atag" continue fi titletag=`/usr/local/bin/titletag.sh $i $grep` if `echo $titletag | grep 1 >/dev/null 2>/dev/null` then echo "disqualified titletag" continue fi h1tag=`/usr/local/bin/h1tag.sh $i $grep` if `echo $h1tag | grep 1 >/dev/null 2>/dev/null` then echo "disqualified h1tag" continue fi Atag=`/usr/local/bin/Atag.sh $i $grep` if `echo $Atag | grep 1 >/dev/null 2>/dev/null` then echo "disqualified Atag" continue fi TITLEtag=`/usr/local/bin/TITLEtag.sh $i $grep` if `echo $TITLEtag | grep 1 >/dev/null 2>/dev/null` then echo "disqualified TITLEtag" continue fi H1tag=`/usr/local/bin/H1tag.sh $i $grep` if `echo $H1tag | grep 1 >/dev/null 2>/dev/null` then echo "disqualified H1tag" continue fi xurl=`echo $url | sed "s/\////g"` p="http://${xurl}" echo " " echo "Creating link in:" echo " $i" echo " " echo "using the phrase: " echo " $grep" echo " " echo "using the url: " echo " $url" echo " " sed "s/lt;$grep /lt;<a href=\"$p\">$phrase<\/a> /" $i | \ sed "s/lt;$grep\//lt;<a href=\"$p\">$phrase<\/a>\//g" | \ sed "s/lt;$grep$/lt;<a href=\"$p\">$phrase<\/a>/" | \ sed "s/lt;$grep>/lt;<a href=\"$p\">$phrase<\/a>>/" | \ sed "s/lt;\/$grep>/lt;\/<a href=\"$p\">$phrase<\/a>>/" | \ sed "s/ $grep=/ <a href=\"$p\">$phrase<\/a>=/" | \ sed "s///\//g" > tmp.$$ mv tmp.$$ $i fi done