The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sed escape char fed.linuxgossip Shell Programming and Scripting 2 10-04-2008 06:41 AM
How to replace any char with newline char. mightysam Shell Programming and Scripting 5 09-18-2008 08:15 PM
char c = 882 useless79 High Level Programming 1 07-30-2007 05:16 AM
char *p and char p[]. arunviswanath High Level Programming 4 07-20-2006 02:11 AM
\n char in C C|[anti-trust] High Level Programming 1 05-05-2005 06:15 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-20-2008
hibern hibern is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 3
Question sed issues with strange char

Hi all,

I try to create a shell script to had the xiti tag at the end of servals web pages just before the <body/> tag.

here is my 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
and here is my error :-(

Code:
sed: -e expression #1, char 39: unterminated `s' command
thanks in advance for your help
  #2 (permalink)  
Old 11-20-2008
jlliagre jlliagre is offline Forum Advisor  
ɹǝsn sıɹɐlosuǝdo
  
 

Join Date: Dec 2007
Location: Paris
Posts: 1,265
Try:
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
Location: Chennai,India
Posts: 13
Arrow

Hi,

Check this

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




Thanks,

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

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Code:
sed -e "s/<body>/${m_tag}/g" "$file" > "$file".tmp && mv -f "$file".tmp "$file"
Drop all the single quotes and use double quotes. Remember, single quotes disable parameter expansion. See the following

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
  
 

Join Date: Nov 2008
Posts: 3
Thanks for your answer, but it's not working :-(

i tried line by line the and i thing this is due to { char. (that' for some thing like a macro)

i have tried with \{ but the problème still their :-(
  #6 (permalink)  
Old 11-23-2008
hibern hibern is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 3
Thumbs up Solved

Thanks for your help, my issue is solved, here is the code :

Quote:
#!/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
Sponsored Links
Closed Thread

Bookmarks

Tags
sed xiti, shell script, shell scripting, unix scripting, unix scripting basics

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 03:13 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0