Sed + xiti

Résolu/Fermé
hibern - 21 nov. 2008 à 01:10
 hibern - 23 nov. 2008 à 10:53
Bonjour,

j'essaye depuis plusieurs jours de faire un script shell qui va me placer le code xiti à la fin de ma page web.
j'ai donc un paquet de page web qui ont une balise <body/> et je voudrais y ajouter juste avant mon code .

voici le code de mon script, malheureusement ça ne fct pas :-(

#!/bin/bash
##################################################################


rm -R /home/hibern/TEMP/hibern
cp -R /home/hibern/TEMP/hibernorig /home/hibern/TEMP/hibern
value=0

cat << EOF > /tmp/xiti.tmp
<!--\
Xt_param = 's=279747&p=';\
try {Xt_r = top.document.referrer;}\
catch(e) {Xt_r = document.referrer; }\
Xt_h = new Date();\
Xt_i = '<img width="39" height="25" border="0" alt="" ';\
Xt_i += 'src="https://logv33.xiti.com/hit.xiti?fh=1&%27+Xt_param;&Rdt=On\
Xt_i += '&hl='+Xt_h.getHours()+'x'+Xt_h.getMinutes()+'x'+Xt_h.getSeconds();\
if(parseFloat(navigator.appVersion)>=4)\
{Xt_s=screen;Xt_i+='&r='+Xt_s.width+'x'+Xt_s.height+'x'+Xt_s.pixelDepth+'x'+Xt_s.colorDepth;}\
document.write(Xt_i+'&ref='+Xt_r.replace(/[<>"]/g, '').replace(/&/g, '$')+'" title="Internet Audience">');\
//-->\
</script>\
<noscript>\
Mesure d'audience ROI statistique webanalytics par <img width="39" height="25" src="https://logv33.xiti.com/hit.xiti?fh=1&s=279747&p=&Rdt=On" alt="WebAnalytics" />\
</noscript></a>\
EOF



for file in `find  /home/hibern/TEMP/hibern -name '*.html' -print`
do

export m_tag=`cat /tmp/xiti.tmp`

sed -e 's/<body>/'$m_tag'/g' "$file" > "$file".tmp && mv -f "$file".tmp "$file"
done




et voici mon message d'erreur

sed: -e expression #1, char 39: unterminated `s' command

3 réponses

jivef Messages postés 927 Date d'inscription mercredi 11 août 2004 Statut Membre Dernière intervention 12 novembre 2020 306
21 nov. 2008 à 04:32
Salut,
Excellent...

Je pense que l'erreur se situe au niveau d'une paire de quote...

(Mais sans certitude...)



A bientux.
0
Bonjour,

Pour ma part je pense , après avoir essayer ligne par ligne que c'est le char. { qui est veux dire le début d'un "programme"/marcro pour le sed. j'ai essayer en mettant \{ mais ca ne résout rien :-(
0
jipicy Messages postés 40842 Date d'inscription jeudi 28 août 2003 Statut Modérateur Dernière intervention 10 août 2020 4 895
21 nov. 2008 à 07:27
0
Merci pour votre aide, cela fonctionne

voici ce que j'ai utilisé

#!/bin/bash
##################################################################


rm -R /home/hibern/TEMP/hibern
cp -R /home/hibern/TEMP/hibernorig /home/hibern/TEMP/hibern

cat << EOF > /tmp/xiti.tmp
<!--\
Xt_param='s=279747&p=';\
try {Xt_r = top.document.referrer;}\
catch(e) {Xt_r = document.referrer; }\
Xt_h = new Date();\
Xt_i=\'<img width="39" height="25" border="0" alt=""\';\
Xt_i +=\'src="http:\/\/logv33.xiti.com\/hit.xiti?\'+Xt_param;\
Xt_i += \'\&hl=\'+Xt_h.getHours()+\'x\'+Xt_h.getMinutes()+\'x\'+Xt_h.getSeconds();\
if(parseFloat(navigator.appVersion)>=4)\
{Xt_s=screen;Xt_i+=\'\&r=\'+Xt_s.width+\'x\'+Xt_s.height+\'x\'+Xt_s.pixelDepth+\'x\'+Xt_s.colorDepth;}\
document.write(Xt_i+\'\&ref=\'+Xt_r.replace(\/[<>"]\/g, \'\').replace(\/&\/g, \'$\')+'" title="Internet Audience">\');\
\/\/-->\
<\/script>\
<noscript>\
Mesure d'audience ROI statistique webanalytics par <img width="39" height="25" src="http:\/\/logv33.xiti.com\/hit.xiti?s=279747&p="\ alt="WebAnalytics" \/>\
<\/noscript><\/a><\/body>
EOF

export m_tag=`cat /tmp/xiti.tmp`
echo "Value for m_tag : "$m_tag

for file in `find  /home/hibern/TEMP/hibern -name '*.html' -print`
do

#sed -e 's/<body\/>/'"$m_tag"'/g' "$file" > "$file".tmp && mv -f "$file".tmp "$file"
sed  -e 's/<\/body>/\'"$m_tag"'/g' "$file" > "$file".tmp && mv -f "$file".tmp "$file"
done

0