Sed + xiti
Résolu
hibern
-
hibern -
hibern -
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 :-(
et voici mon message d'erreur
sed: -e expression #1, char 39: unterminated `s' command
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
Configuration: Linux Firefox 3.0.2
3 réponses
-
Salut,
Excellent...
Je pense que l'erreur se situe au niveau d'une paire de quote...
(Mais sans certitude...)
A bientux.
-
Salut,
Change tes délimiteurs : Introduction à SED - Délimiteur de commande
Voir aussi : Introduction à SED - Le remplacement de variables
Sed - Insertion de texte
-
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