updating the Bash version in a script

updating the Bash version in a script

Post by Casimiro Lovato-Winst » Fri, 08 Mar 2002 08:06:56



Hello everybody,

I need to make sure that a bash script checks for a version of Bash
that is greater than 1.x. If the version is < 2.0 it needs to update
the version of bash and then continue using the updated version.

I can get the version using the $BASH_VERSION variable and use the
version to make the decision to do something. WHat I don't know how to
do is update the version and then use it in the same process as the
script.

I tried something like (and go ahead and flame me I'm new to Bash
programming):
/shell_source/new_bash
which starts a new process that does not carry on the program. trying
to use fg to bring it back to the foreground did not work either.

I'm sure this is probably fairly simple and I appreciate any
suggestions.
Thanks,

Casimiro

 
 
 

updating the Bash version in a script

Post by Barry Margoli » Fri, 08 Mar 2002 09:49:18




>Hello everybody,

>I need to make sure that a bash script checks for a version of Bash
>that is greater than 1.x. If the version is < 2.0 it needs to update
>the version of bash and then continue using the updated version.

>I can get the version using the $BASH_VERSION variable and use the
>version to make the decision to do something. WHat I don't know how to
>do is update the version and then use it in the same process as the
>script.

>I tried something like (and go ahead and flame me I'm new to Bash
>programming):
>/shell_source/new_bash
>which starts a new process that does not carry on the program. trying
>to use fg to bring it back to the foreground did not work either.


--

Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

updating the Bash version in a script

Post by Chris F.A. Johnso » Fri, 08 Mar 2002 16:15:51



> Hello everybody,

> I need to make sure that a bash script checks for a version of Bash
> that is greater than 1.x. If the version is < 2.0 it needs to update
> the version of bash and then continue using the updated version.

> I can get the version using the $BASH_VERSION variable and use the
> version to make the decision to do something. WHat I don't know how to
> do is update the version and then use it in the same process as the
> script.

> I tried something like (and go ahead and flame me I'm new to Bash
> programming):
> /shell_source/new_bash
> which starts a new process that does not carry on the program. trying
> to use fg to bring it back to the foreground did not work either.

> I'm sure this is probably fairly simple and I appreciate any
> suggestions.

    Do you mean you want to download a new version of bash,
    configure, compile, and install it, then run the script with
    it?

    Or do you want to run it with a newer version of bash
    already installed on the system?

    If the latter, just use a shebang with the path to the newer
    version at the top of the script file, e.g.:

        #!/usr/local/bin/bash2

    (Some distributions of Linux use[d] bash-1 as the default,
    but include version 2 as as bash2.)

    If you mean the latter:

        if [ ${BASH_VERSION%%.*} -lt 2 ]
        then
            wget ftp://ftp.gnu.org/gnu/bash/bash-2.05a.tar.gz &&
            gunzip -c bash-2.05a.tar.gz | tar x &&
            cd bash-2.05a &&
            ./configure && make && exec ./bash SCRIPT || {
            echo "installation of bash unsucessful"; exit; }
        fi

        ## rest of script goes here

--

        =================================================================


 
 
 

updating the Bash version in a script

Post by Casimiro Lovato-Winst » Sat, 09 Mar 2002 03:05:31


Thanks a million,
I used a combination of your posts and it works like a charm



> > Hello everybody,

> > I need to make sure that a bash script checks for a version of Bash
> > that is greater than 1.x. If the version is < 2.0 it needs to update
> > the version of bash and then continue using the updated version.

> > I can get the version using the $BASH_VERSION variable and use the
> > version to make the decision to do something. WHat I don't know how to
> > do is update the version and then use it in the same process as the
> > script.

> > I tried something like (and go ahead and flame me I'm new to Bash
> > programming):
> > /shell_source/new_bash
> > which starts a new process that does not carry on the program. trying
> > to use fg to bring it back to the foreground did not work either.

> > I'm sure this is probably fairly simple and I appreciate any
> > suggestions.

>     Do you mean you want to download a new version of bash,
>     configure, compile, and install it, then run the script with
>     it?

>     Or do you want to run it with a newer version of bash
>     already installed on the system?

>     If the latter, just use a shebang with the path to the newer
>     version at the top of the script file, e.g.:

>            #!/usr/local/bin/bash2

>     (Some distributions of Linux use[d] bash-1 as the default,
>     but include version 2 as as bash2.)

>     If you mean the latter:

>            if [ ${BASH_VERSION%%.*} -lt 2 ]
>         then
>             wget ftp://ftp.gnu.org/gnu/bash/bash-2.05a.tar.gz &&
>             gunzip -c bash-2.05a.tar.gz | tar x &&
>             cd bash-2.05a &&
>             ./configure && make && exec ./bash SCRIPT || {
>             echo "installation of bash unsucessful"; exit; }
>         fi

>         ## rest of script goes here

 
 
 

1. Version 1.9 update of "Advanced Bash Scripting Guide"

Announcing the version 1.9 release of the "Advanced Bash Scripting Guide."
This e-book tutorial and reference is the equivalent of a 536-page print book.
With 263 illustrative examples, the book covers virtually every aspect of
scripting.

The author invites comparisons with *any* of the commercially printed books on
shell scripting. His aim was to write "best of category" documentation.

          "This  tutorial  assumes  no previous knowledge of
           scripting or programming, but progresses rapidly  toward an
           intermediate/advanced level of instruction ...all the while
           sneaking in little snippets of UNIX wisdom and lore. It serves
           as a textbook, a manual for self-study, and  a  reference
           and source of knowledge on shell scripting techniques. The
           exercises and heavily-commented  examples invite active reader
           participation, under the premise that the only way to really
           learn scripting is to write scripts."
                -- from the Introduction

License: Open Publication License
         This means the book is *free* and freely distributable.

URLs:
----

Linux Documentation Project:
http://www.tldp.org/LDP/abs/html/
http://www.tldp.org/LDP/abs/html/index.html
http://www.tldp.org/LDP/abs/abs-guide.html.tar.gz
 http://www.tldp.org/LDP/abs/abs-guide.pdf

Sunsite:
http://www.ibiblio.org/pub/Linux/docs/linux-doc-project/abs-guide/

Author's home page:
http://personal.riverusers.com/~thegrendel/abs-guide-1.9.tar.bz2  [ 541k ]
   (bzip2-ed tarball containing SGML source, all example scripts,
    and rendered HTML)

##########################################################################

# PLEASE remember a short description of the software and the LOCATION.  #
# This group is archived at http://stump.algebra.com/~cola/              #
##########################################################################

2. source for convert utility

3. Advanced Bash Scripting Guide: Version 1.8 update

4. can't compile gnome with latest gtk!(1.1.3)

5. BASH BASH BASH BASH BASH BASH BASH BASH BASH BASH

6. two IP-numbers for one interface?

7. Advanced Bash Scripting Guide update

8. Metro Link Motif 2.0 under FreeBSD?

9. Advanced Bash Scripting Guide, version 1.0 release

10. Announcing: version 2.7 release of the "Advanced Bash Scripting Guide."

11. Updated version of hinv perl script

12. update plug-ins in netscape 6.1

13. Version Update/Package Update