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
Tables to query to find users for database from shell script pinnacle Shell Programming and Scripting 0 04-10-2009 05:18 PM
to find whether update query is successfull or not using Ksh Script ali560045 Shell Programming and Scripting 3 01-07-2009 01:41 AM
find -mtime query Rajat UNIX for Dummies Questions & Answers 1 07-09-2008 07:12 AM
query about find and -exec shriashishpatil UNIX for Advanced & Expert Users 2 04-12-2007 01:16 AM
find -perm query napolayan UNIX for Dummies Questions & Answers 1 11-28-2006 02:28 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 Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-27-2009
lightdensity lightdensity is offline
Registered User
  
 

Join Date: May 2009
Posts: 6
Quote:
Originally Posted by devtakh View Post
Code:
sed '/Server=127.0.0.1/{s//Server=0.0.0.0/g}
/ServerPort=0/{s//ServerPort=1/g}
/Enable Server=1/{s//Enable Server=0/g}
' /opt/server.conf > /opt/new_server.conf
-Devaraj Takhellambam
hi,

As soon as i think, i am getting use to shell script .. some or the other errors occurs.
My previous code is working fine execpt for
Code:
 elif [ -n "`echo ${line} | grep 'DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl'`" ]
 then
       echo ${line} | sed 's|DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl|DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl|g' >>$FILE1
this is throwing error
Code:
./sendmail.sh: line 19: unexpected EOF while looking for matching ``'
./sendmail.sh: line 33: syntax error: unexpected end of file
Pl me help on this..
  #2 (permalink)  
Old 05-26-2009
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,522
if you have Python
Code:
#!/usr/bin/env python
import fileinput
d={ "Server":"0.0.0.0", "ServerPort":"1", "Enable Server":"0" }
for line in fileinput.FileInput("file",inplace=1):
    line=line.strip()
    if not line.startswith("#") and line!="":
        line=line.split("=")        
        print line[0]+"="+d[line[0]]
    else:
        print line
output
Code:
# ./test.py
# more file
### Welcome to server ###
### Server address and port ###

Server=0.0.0.0
### Replace Server=0.0.0.0 ###

ServerPort=1
### Replace ServerPort=1 ####
### Enable Server ##

Enable Server=0

### Replace Enable Server=0 ###
### END OF FILE ##
  #3 (permalink)  
Old 05-27-2009
mnmonu mnmonu is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 32
follow this code:

find . -type f | xargs sed -i "s/Server=127.0.0.1/Server=0.0.0.0/g"
  #4 (permalink)  
Old 05-27-2009
lightdensity lightdensity is offline
Registered User
  
 

Join Date: May 2009
Posts: 6
Quote:
Originally Posted by mnmonu View Post
follow this code:

find . -type f | xargs sed -i "s/Server=127.0.0.1/Server=0.0.0.0/g"
hi mnmonu,

I am still new to shell script, can you explain me as where to and how to use find . -type f | xargs sed -i "s/Server=127.0.0.1/Server=0.0.0.0/g" in my mentioned code..

thanks

-----Post Update-----

hi devtakh

Sorry mate for bothering you with so many question.. There was problem in my script and i found it.. Now output is coming very correctly...

Thanks man.. Really appreciate your response..

Thanks to all who gave their valuable suggestions.

Last edited by lightdensity; 05-27-2009 at 06:57 AM..
Bits Awarded / Charged to lightdensity for this Post
Date User Comment Amount
05-27-2009 allrise123 N/A 100
  #5 (permalink)  
Old 05-27-2009
allrise123 allrise123 is offline
Registered User
  
 

Join Date: May 2009
Posts: 9
hey,

even i was facing similar query.. your posts helped me
Closed Thread

Bookmarks

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 09:59 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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