The UNIX and Linux Forums  

Go Back   Les systèmes UNIX et Linux Forums > Top Forums > De programmation et de script Shell
.
google unix.com



De programmation et de script Shell Posez vos questions à propos de KSH, CSH, SH, BASH, PERL, PHP, SED, awk et d'autres scripts shell et les langages de script shell ici.

Plus d'UNIX et Linux Forum Sujets Vous trouverez peut-être utile
Fil Thread Starter Forum Réponses Last Post
sed échapper char fed.linuxgossip De programmation et de script Shell 2 10-04-2008 07:41 AM
Comment faire pour remplacer tous les caractères de nouvelle char. mightysam De programmation et de script Shell 5 09-18-2008 09:15 PM
char c \u003d 882 useless79 High Level Programming 1 07-30-2007 06:16 AM
char * p et p char []. arunviswanath High Level Programming 4 07-20-2006 03:11 AM
\ n char en C C | [anti-trust] High Level Programming 1 05-05-2005 07:15 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Recherche sur ce Thread Rate Thread Modes d'affichage
  #1 (permalink)  
Old 11-20-2008
hibern hibern is offline
Registered User
  
 

Date d'inscription: novembre 2008
Messages: 3
Question sed questions étrange char

Salut à tous,

J'essaie de créer un script shell pour xiti le tag avait à la fin de servals pages Web, juste avant la balise <body/>.

voici mon script:


Code:
#!/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="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>\
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 erreur :-(


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

Merci d'avance pour votre aide
  #2 (permalink)  
Old 11-20-2008
jlliagre jlliagre is offline Forum Advisor  
ɹǝsn sıɹɐlosuǝdo
  
 

Join Date: Dec 2007
Lieu: Paris
Messages: 1496
Essayez:

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

  #3 (permalink)  
Old 11-21-2008
mailme0712 mailme0712 is offline
Registered User
  
 

Join Date: Sep 2008
Endroit: Chennai, Inde
Messages: 13
Arrow

Salut,

Cochez cette

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




Merci,

Thangaraju
  #4 (permalink)  
Old 11-21-2008
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Lieu: Bangalore, Inde
Posts: 2798

Code:
sed -e "s/<body>/${m_tag}/g" "$file" > "$file".tmp && mv -f "$file".tmp "$file"

Déposer tous les guillemets simples et l'utilisation des guillemets. Rappelez-vous, les guillemets simples désactiver paramètre expansion. Voir la suite


Code:
[/tmp]$ a='some text'
[/tmp]$ echo $a
some text
[/tmp]$ echo '$a'
$a
[/tmp]$ echo "$a"
some text

  #5 (permalink)  
Old 11-21-2008
hibern hibern is offline
Registered User
  
 

Date d'inscription: novembre 2008
Messages: 3
Merci pour votre réponse, mais il ne fonctionne pas :-(

j'ai essayé la ligne par ligne et i chose, cela est dû à (char. (que «pour quelque chose comme un macro)

J'ai essayé avec \ (, mais le problème reste leur :-(
  #6 (permalink)  
Old 11-23-2008
hibern hibern is offline
Registered User
  
 

Date d'inscription: novembre 2008
Messages: 3
Thumbs up Solved

Merci pour votre aide, mon problème est résolu, voici le code:

Citation:
#! / 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 \u003d 's \u003d 279747 & p \u003d'; \
try (Xt_r \u003d top.document.referrer;) \
catch (e) (Xt_r \u003d document.referrer;) \
Xt_h \u003d new Date (); \
Xt_i \u003d \ '<img width \u003d "39" height \u003d "25" border \u003d "0" alt \u003d "" \ ", \
Xt_i + \u003d 'src \u003d "http: \ / \ / logv33.xiti.com \ / hit.xiti? \' + Xt_param; \
Xt_i + \u003d \ '\ & hl \u003d \' + Xt_h.getHours () + \ 'x \' + Xt_h.getMinutes () + \ 'x \' + Xt_h.getSeconds (); \
if (parseFloat (navigator.appVersion)> \u003d 4) \
(\u003d Xt_s écran; Xt_i + \u003d \ '\ & r \u003d \' Xt_s.width + + \ 'x \' Xt_s.height + + \ 'x \' Xt_s.pixelDepth + + \ 'x \' + Xt_s.colorDepth;) \
document.write (Xt_i + \ '\ & ref \u003d' + Xt_r.replace (\ /[<>"] \ / g, \ '\'). remplacer (\ / & \ / g, \ '$ \') + "" title \u003d "Internet Audience"> \ '); \
\ / \ / -> \
<\ / script> \
<noscript> \
Mesure d'audience ROI statistique WebAnalytics par <img width \u003d "39" height \u003d "25" src \u003d "http: \ / \ / logv33.xiti.com \ / hit.xiti? S \u003d 279747 & p \u003d" \ alt \u003d "WebAnalytics "\ /> \
<\ / noscript> <\ / a> <\ / body>
EOF
l'exportation m_tag \u003d `cat / tmp / xiti.tmp»
echo "Valeur de m_tag:" $ m_tag
pour trouver des fichiers dans `/ home / hibern / TEMP / hibern-name '*. html'-print`
faire
#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"
fait
Closed Thread

Bookmarks

Tags
sed xiti, shell script, shell scripting, scripts unix, unix scripts de base

Thread Tools Recherche sur ce Thread
Recherche sur ce Thread:

Recherche avancée
Modes d'affichage Rate this thread
Rate this thread:

Règles de messages
Tu mai pas de nouvelles discussions: nonoui
Tu mai pas envoyer des réponses:
Tu mai pas envoyer des pièces jointes
Tu mai pas modifier vos messages

BB code est Sur
Smilies sont Sur
[IMG] code est Sur
Le code HTML est Hors tension
Trackbacks sont Sur
Pingbacks sont Sur
Refbacks sont Sur




Toutes les heures sont au format GMT -4. Le temps est maintenant 02:16 AM.


Powered by: vBulletin, Copyright © 2000 - 2006, Jelsoft Enterprises Limited. Traductions Langue Powered by .
vBCredits v1.4 Copyright © 2007 - 2008, PixelFX Studios
Les systèmes UNIX et Linux Forums Content Copyright © 1993-2009. Tous droits Reserved.Ad de gestion par RedTyger

Content Relevant URLs par vBSEO 3.2.0