Re: editing httpd.conf file through shell script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You can use head and tail commands in shell to do what you want to do. You could do something like:
 
x=`grep -n "DocumentRoot /websites/vodafone/web" httpd.conf` # gets the line number
cat httpd.conf|head -$x > tmp.conf
echo "AddType application/x-httpd-php .php" >> tmp.conf
cat httpd.conf|tail +$x >> tmp.conf
mv tmp.conf httpd.conf
 
Above code is not tested. It's just for your understanding.


 
On 6/18/08, Agnello George <agnello.dsouza@xxxxxxxxx> wrote:

hi

i am trying to edit my httpd.comf file through a shell script ......      (( actually I trying to set up a control panel ))  

my httpd.conf host directives for many domains  , the file is  something like this :
 

##########START#######rodney.com###################

<VirtualHost 192.168.0.244:80>
ServerAdmin admin@xxxxxxxxxxxxxxxxxxxxxxxx
ServerName rodney.sys.qualiproj.qualispace.com
ServerAlias www.rodney.sys.qualiproj.qualispace.com
DocumentRoot /websites/rodney.com/web
ErrorLog /websites/rodney.com/logs/rodney.sys.qualiproj.error_log
CustomLog /websites/rodney.com/logs/rodney.sys.qualiproj.access_log common
</VirtualHost>
##########END############rodney.com###################


#########START#########vodafone###################

<VirtualHost 192.168.0.244:80>
ServerAdmin admin@xxxxxxxxxxxxxxxxxxxxxxxx
ServerName fff.sys.qualiproj.qualispace.com
ServerAlias www.fff.sys.qualiproj.qualispace.com
DocumentRoot /websites/vodafone/web
ErrorLog /websites/vodafone/logs/fff.sys.qualiproj.error_log
CustomLog /websites/vodafone/logs/fff.sys.qualiproj.access_log common
</VirtualHost>
#########END#########vodafone2631###################
 
now through a shell script i need to add mime type  for domain vodafone.com , i would  need to add the following bellow "DoucmentRoot"
 
AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

How can this be done ? would i need to know Perl scripting ..or can this be done without the knowledge of Perl

Your help would be of great value !!

--
Regards
Agnello Dsouza
www.linux-vashi.blogspot.com
 


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux