Hi:
Well, I have to make an update some Bash Scripts, running under one Linux / Apache server. All I need is to perform 6 types of operations in all of them. For the example of the operations I need, let's imagine an httpd.conf file, like this:
<virtualhost 200.157.211.200>
ServerAdmin [email protected]
ServerName www.folhadazonanorte.com.br
ServerAlias folhadazonanorte.com.br
DocumentRoot /home/folhadazonanorte/www
ScriptAlias /cgi-bin/ /home/folhadazonanorte/www/cgi-folhadazonanorte/
TransferLog logs/folhadazonanorte-access-log
</virtualhost>
<virtualhost 200.157.211.200>
ServerAdmin [email protected]
ServerName www.uncensored.com.br
ServerAlias uncensored.com.br
ServerAlias abcd.com.br
DocumentRoot /home/uncensored/www
ScriptAlias /cgi-bin/ /home/uncensored/www/cgi-uncensored/
TransferLog logs/uncensored-access-log
</virtualhost>
<virtualhost 200.157.211.200>
ServerAdmin [email protected]
ServerName www.thorimobiliaria.com.br
ServerAlias thorimobiliaria.com.br
DocumentRoot /home/thorimobiliaria/www
ScriptAlias /cgi-bin/ /home/thorimobiliaria/www/cgi-thorimobiliaria/
TransferLog logs/thorimobiliaria-access-log
</virtualhost>
1) After asking at the prompt, I have the string: "uncensored.com.br". I want to read this file until matching the record where it is "ServerName www.uncensored.com.br". Then delete from <virtualhost 200.157.211.200>, two lines above, until the next <virtualhost 200.157.211.200>. That is, I want to delete the entire Virtualhost block for the domain "uncensored.com.br".
2) In the same way, after asking at the prompt, I have the string "abcd.com.br" and I want to delete just that record "ServerAlias abcd.com.br".
OBS: On these 2 first operations consider I am reading a work version of httpd.conf and writing another work version updated, called, let's say, httpd.conf.updated.
3) On a Bash Script, how to give a prompt message, through echo command, for instance, putting some words in colors, to call attention? Is it possible?
4) On a Bash Script, if I call for execution a command or a program, like, for instance, "rm", "cp", "passwd", and these commands / programs ask something I have to answer, so that the command / program proceed, how to do this?
5) On a Bash Script how to test to see if the user really typed anything after a prompt question by echo command?
6) On a Bash Script how to test if which the user entered is an specific string teh script is waiting for?
Thanks a lot.
Mario./
Well, I have to make an update some Bash Scripts, running under one Linux / Apache server. All I need is to perform 6 types of operations in all of them. For the example of the operations I need, let's imagine an httpd.conf file, like this:
<virtualhost 200.157.211.200>
ServerAdmin [email protected]
ServerName www.folhadazonanorte.com.br
ServerAlias folhadazonanorte.com.br
DocumentRoot /home/folhadazonanorte/www
ScriptAlias /cgi-bin/ /home/folhadazonanorte/www/cgi-folhadazonanorte/
TransferLog logs/folhadazonanorte-access-log
</virtualhost>
<virtualhost 200.157.211.200>
ServerAdmin [email protected]
ServerName www.uncensored.com.br
ServerAlias uncensored.com.br
ServerAlias abcd.com.br
DocumentRoot /home/uncensored/www
ScriptAlias /cgi-bin/ /home/uncensored/www/cgi-uncensored/
TransferLog logs/uncensored-access-log
</virtualhost>
<virtualhost 200.157.211.200>
ServerAdmin [email protected]
ServerName www.thorimobiliaria.com.br
ServerAlias thorimobiliaria.com.br
DocumentRoot /home/thorimobiliaria/www
ScriptAlias /cgi-bin/ /home/thorimobiliaria/www/cgi-thorimobiliaria/
TransferLog logs/thorimobiliaria-access-log
</virtualhost>
1) After asking at the prompt, I have the string: "uncensored.com.br". I want to read this file until matching the record where it is "ServerName www.uncensored.com.br". Then delete from <virtualhost 200.157.211.200>, two lines above, until the next <virtualhost 200.157.211.200>. That is, I want to delete the entire Virtualhost block for the domain "uncensored.com.br".
2) In the same way, after asking at the prompt, I have the string "abcd.com.br" and I want to delete just that record "ServerAlias abcd.com.br".
OBS: On these 2 first operations consider I am reading a work version of httpd.conf and writing another work version updated, called, let's say, httpd.conf.updated.
3) On a Bash Script, how to give a prompt message, through echo command, for instance, putting some words in colors, to call attention? Is it possible?
4) On a Bash Script, if I call for execution a command or a program, like, for instance, "rm", "cp", "passwd", and these commands / programs ask something I have to answer, so that the command / program proceed, how to do this?
5) On a Bash Script how to test to see if the user really typed anything after a prompt question by echo command?
6) On a Bash Script how to test if which the user entered is an specific string teh script is waiting for?
Thanks a lot.
Mario./