1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Some Bash Scripts Programming Hints

Discussion in 'Software Development' started by mariolima, Sep 8, 2004.

Thread Status:
Not open for further replies.
  1. mariolima

    mariolima Thread Starter

    Joined:
    Nov 4, 2002
    Messages:
    24
    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./
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/271840

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice