LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-26-2009, 04:44 AM   #1
cioannou
LQ Newbie
 
Registered: Apr 2005
Location: Athens-Greece
Distribution: Mandrake 10.1CE
Posts: 28

Rep: Reputation: 15
Command line INI / config file editor


Hello,

What I am trying to do is create an easy way to install a mail server in Debian.

So I want ask the user for some value and then enter that value in PHP.INI or postfix master.cf etc.

Is there any way I can change the config files from command line?
 
Old 05-26-2009, 09:21 AM   #2
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
"sed" is a stream editor. It can be used to edit files programatically, from command lines or from a script. It's not the friendliest thing in the world though
 
Old 05-26-2009, 09:25 AM   #3
cioannou
LQ Newbie
 
Registered: Apr 2005
Location: Athens-Greece
Distribution: Mandrake 10.1CE
Posts: 28

Original Poster
Rep: Reputation: 15
Thanks,

I already use sed for simple things like replacing xxxx = On to xxxx = Off

the main problem is with postfix master.cf where I need to add/modify lines in a specific place

For example:

in the smtp service line I need to add
Code:
smtp      inet  n       -       -       -       -       smtpd
	-o content_filter=spamassassin

below that I need to add:
Code:
spamassassin unix -     n       n       -       -       pipe
	user=spamd argv=/usr/bin/spamc -f -e
	/usr/sbin/sendmail -oi -f ${sender} ${recipient}
dovecot   unix  -       n       n       -       -       pipe
    flags=DRhu user=vmail:mail argv=/usr/lib/dovecot/deliver -d ${recipient}
Any ideas?
 
Old 05-26-2009, 09:39 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You an use pattern matching to select a line and the `a' command to add a line below the one that was matched:
sed '/user=spamd/a\
/usr/sbin/sendmail -oi -f ${sender} ${recipient}' master.cf >master.cf.new

Another technique could be to collect all of the variable parts of master.cf, from the old one & the user, and then construct a new one in it's entirety using a HERE document with variables.

Last edited by jschiwal; 05-26-2009 at 09:42 AM.
 
Old 05-26-2009, 04:21 PM   #5
cioannou
LQ Newbie
 
Registered: Apr 2005
Location: Athens-Greece
Distribution: Mandrake 10.1CE
Posts: 28

Original Poster
Rep: Reputation: 15
Thanks will try that
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
command line//text editor Fred Caro Linux - Newbie 6 02-18-2009 11:23 AM
document editor for command-line snama Linux - Software 3 06-24-2008 02:43 PM
vi editor/command line free guide fhameed Linux - Software 3 12-12-2003 09:16 AM
VI text editor in command line InSane103 Linux - Software 4 07-09-2003 09:04 PM
vi as Command Line Editor taz75 Linux - Newbie 8 01-04-2002 01:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:09 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
Open Source Consulting | Domain Registration