LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 02-24-2005, 07:12 AM   #1
mikz
Member
 
Registered: Sep 2004
Distribution: Slackware current
Posts: 109

Rep: Reputation: 15
Simple shell script


How do I write a shell script that will:

search through sendmail.mc file

change the line
define(`SMART_HOST',`smtp.myisp.com')
to
define(`SMART_HOST',`smtp.ourisp.com')

then exit
 
Old 02-24-2005, 08:18 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Hi,

First of all: The quoting is not correct (back qoute to open, single quote to close). Should both be single quotes.

Here's one solution using sed and taking the whole string (you migth be able to shorten the string, but do watch out for false hits)

Code:
#!/bin/bash

# for sed versions < 4.0, but works with all sed version including 4+.
mv /etc/mail/sendmail.cf /etc/mail/sendmail.cf.org
sed "s/define('SMART_HOST','smtp.myisp.com')/define('SMART_HOST','smtp.ourisp.com')/" /etc/mail/sendmail.cf.org > /etc/mail/sendmail.cf

# The command below only works with sed => 4.0 (sed -V to check this)
# sed -i.org "s/define('SMART_HOST','smtp.myisp.com')/define('SMART_HOST','smtp.ourisp.com')/" /etc/mail/sendmail.cf
Make sure you have a backup of the original sendmail.cf before you start testing/trying.

Hope this helps.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Shell Script Help Kristijan Programming 3 06-13-2005 10:13 PM
simple shell script sharpie Programming 9 06-03-2004 12:47 AM
simple shell script Greg_courageous Programming 2 05-12-2004 05:34 PM
Very Simple Shell Script cli_man Linux - Software 5 04-24-2003 11:14 AM
Simple C Shell script is not so simple elconde Programming 2 09-17-2001 12:53 AM


All times are GMT -5. The time now is 05:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration