The UNIX and Linux Forums  

Go Back   O UNIX e Linux Forum > Top Fóruns > Programação Shell Script e
.
google unix.com



Programação Shell Script e Post perguntas sobre ksh, CSH, SH, BASH, Perl, PHP, SED, Awk e outros scripts shell e shell scripts línguas aqui.

Mais UNIX e Linux Fórum Tópicos Você pode achar Helpfull
Fio Thread Starter Fórum Respostas Última postagem
sed escapar char fed.linuxgossip Programação Shell Script e 2 10-04-2008 07:41
Como substituir qualquer char com char newline. mightysam Programação Shell Script e 5 09-18-2008 09:15
char c \u003d 882 useless79 Alto Nível de programação 1 07-30-2007 06:16
char * p e char p []. arunviswanath Alto Nível de programação 4 07-20-2006 03:11
\ n char em C C | [anti-trust] Alto Nível de programação 1 05-05-2005 07:15

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 Pesquisar este Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-20-2008
hibern hibern is offline
Usuário
  
 

Join Date: Nov 2008
Posts: 3
Question sed questões com estranhos char

Oi tudo,

Tento criar um shell script que tinha a etiqueta xiti no final de páginas da web servals pouco antes da <body/> tag.

aqui é o meu script:


Código:
#!/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

e aqui está o meu erro :-(


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

Agradecemos antecipadamente a sua ajuda
  #2 (permalink)  
Old 11-20-2008
jlliagre jlliagre is online now Forum Advisor  
sıɹɐlosuǝdo ɹǝsn
  
 

Join Data: dezembro 2007
Localização: Paris
Posts: 1.496
Experimente:

Código:
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
Usuário
  
 

Join Date: Sep 2008
Location: Chennai, Índia
Lugares: 13
Arrow

Oi,

Marque esta

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




Obrigado,

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

Join Date: Feb 2005
Local: Bangalore, Índia
Mensagens: 2.798

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

Largar tudo o único aspas e usar aspas. Lembre-se, único parâmetro aspas desativar expansão. Consulte o seguinte


Código:
[/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
Usuário
  
 

Join Date: Nov 2008
Posts: 3
Obrigado pela sua resposta, mas não é trabalho :-(

Tentei linha por linha, a coisa e eu este é devido a (char. (que "por alguma coisa como um macro)

Tenho tentado com \ (, mas o problema continua a sua :-(
  #6 (permalink)  
Old 11-23-2008
hibern hibern is offline
Usuário
  
 

Join Date: Nov 2008
Posts: 3
Thumbs up Resolvido

Obrigado pela vossa ajuda, o meu problema é resolvido, aqui está o código:

Citação:
#! / 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) \
(Xt_s \u003d screen; 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, \ '\'). replace (\ / & \ / g, \ '$ \') + "title \u003d" Internet Audiência "> \ '); \
\ / \ / -> \
<\ / script> \
<noscript> \
Mesure d'audience ROI statistique par WebAnalytics <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
exportação m_tag \u003d `cat / tmp / xiti.tmp»
echo "Valor para m_tag:" $ m_tag
para encontrar arquivos em `/ home / hibern / TEMP / hibern-name '*. html'-print`
fazer
#sed -e 's / <body\/> /' "$ m_tag" '/ g' "$ file"> "$ file". tmp & & mv-f "$ arquivo". tmp "$ file"
sed -e 's / <\ / body> / \' "$ m_tag" '/ g' "$ file"> "$ file". tmp & & mv-f "$ arquivo". tmp "$ file"
feito
Closed Thread

Marcadores

Tags
sed xiti, shell script, shell script, unix script, unix script básico

Thread Tools Pesquisar este Thread
Pesquisar este Thread:

Pesquisa Avançada
Display Modes Esta taxa Thread
Esta taxa Thread:

Destacamento Regimento
Você não pode postar novas threads
Você não pode postar respostas
Você não pode postar anexos
Você não pode editar suas postagens

BB code é Ligado
Smilies são Ligado
[IMG] código é Ligado
Código HTML é Desligado
Trackbacks são Ligado
Pingbacks são Ligado
Refbacks são Ligado




Todos os horários são GMT -4. A hora é agora 06:33.


Powered by: vBulletinCopyright © 2000 - 2006, Jelsoft Enterprises Limited. Língua Traduções Powered by .
vBCredits v1.4 Copyright © 2007 - 2008, PixelFX Studios
O UNIX e Linux Fóruns Content Copyright © 1993-2009. Todos os Direitos Reserved.Ad Gestão por RedTyger

Content Relevant URLs por vBSEO 3.2.0