Results 1 to 5 of 5
I want to write a script that auto modify httpd.conf.
I want to ADD a line "ServerName XXXXX"
and
REPLACE the DocumentRoot
Any hints? thanks....
- 12-17-2009 #1Just Joined!
- Join Date
- Dec 2009
- Posts
- 2
Script add/replace string in file
I want to write a script that auto modify httpd.conf.
I want to ADD a line "ServerName XXXXX"
and
REPLACE the DocumentRoot
Any hints? thanks.
- 12-17-2009 #2
have you tried sed command?
man sed- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 12-17-2009 #3Just Joined!
- Join Date
- May 2006
- Posts
- 4
Follwing is the simple shell script to auto modify your httpd.conf. Modify path in script accordingly
#for adding a line, append the line in httpd.conf
echo "ServerName XXXXX" >> httpd.conf
#for replacing, use sed or grep command, using grep
grep -v "DocumentRoot" httpd.conf >httpd.conf.tmp
echo "DocumentRoot your_document_root_path" >>httpd.conf.tmp
mv httpd.conf.tmp httpd.conf
- 12-19-2009 #4Just Joined!
- Join Date
- Dec 2009
- Posts
- 5
Use Vi editor:
%s/string-to-replace/replace-with-string/
- 12-21-2009 #5Just Joined!
- Join Date
- Dec 2009
- Posts
- 5
find . -type f -exec sed -i -e 's/DocumentRoot/ServerName XXXXX/g' {} \;


Reply With Quote
