[bash script] running functions "at same time" - Slackware

This is a discussion on [bash script] running functions "at same time" - Slackware ; Hi, I have a bash script with several functions. I need to run them "in a parallel way" like a "threads", I mean I don't want to wait to finish executing each before continuing to the next one in the ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: [bash script] running functions "at same time"

  1. [bash script] running functions "at same time"

    Hi,

    I have a bash script with several functions.
    I need to run them "in a parallel way" like a "threads", I mean I
    don't want to wait to finish executing each before continuing to the
    next one in the script.
    BTW, I need to run them on a single script so I cannot extract them
    and make new scripts for every function.

    For the following example:

    #!/bin/bash
    function one()
    function two()
    function three()
    #launching functions
    one
    two
    trhee
    #end

    I want to execute function one and continue with the others, so one
    should be running while function two is executing as well, same for
    function three.

    Possible? How can i do that?

    Thanks as always,
    Jaisol

  2. Re: [bash script] running functions "at same time"

    jaisol wrote:
    > Hi,
    >
    > I have a bash script with several functions.
    > I need to run them "in a parallel way" like a "threads", I mean I
    > don't want to wait to finish executing each before continuing to the
    > next one in the script.
    > BTW, I need to run them on a single script so I cannot extract them
    > and make new scripts for every function.
    >
    > For the following example:
    >
    > #!/bin/bash
    > function one()
    > function two()
    > function three()
    > #launching functions
    > one
    > two
    > trhee
    > #end
    >
    > I want to execute function one and continue with the others, so one
    > should be running while function two is executing as well, same for
    > function three.
    >
    > Possible? How can i do that?
    >
    > Thanks as always,
    > Jaisol


    Depends, do the have side-effects? As in modifying variables from the
    main script? If not just put & at the end like any normal program.
    Bash will start each one in a sub-shell. If they depend on side-effects
    you'll have to be more inventive.

    Jerry

  3. Re: [bash script] running functions "at same time"

    On Fri, 22 Aug 2008 13:09:59 -0700 (PDT), jaisol wrote:

    >Hi,
    >
    >I have a bash script with several functions.
    >I need to run them "in a parallel way" like a "threads", I mean I
    >don't want to wait to finish executing each before continuing to the
    >next one in the script.
    >BTW, I need to run them on a single script so I cannot extract them
    >and make new scripts for every function.
    >
    >For the following example:
    >
    >#!/bin/bash
    > function one()
    > function two()
    > function three()
    >#launching functions
    >one
    >two
    >trhee
    >#end
    >
    >I want to execute function one and continue with the others, so one
    >should be running while function two is executing as well, same for
    >function three.
    >
    >Possible? How can i do that?


    Of course it's possible, wrong group, try comp.newbie.homework.help

    Grant.
    --
    http://bugsplatter.id.au/

  4. Re: [bash script] running functions "at same time"

    On Fri, 22 Aug 2008 13:09:59 -0700, jaisol wrote:

    > I have a bash script with several functions. I need to run them "in a



    Sure ya do. Looks like another day's homework assignment to me. Weren't
    you just here asking for homework help a day or two ago?

    Bugger off, schoolboy.


    --
    "Ubuntu" -- an African word, meaning "Slackware is too hard for me".
    The Usenet Improvement Project: http://improve-usenet.org


  5. Re: [bash script] running functions "at same time"

    On Fri, 22 Aug 2008 13:09:59 -0700, jaisol sprout:

    > Hi,
    >
    > I have a bash script with several functions. I need to run them "in a
    > parallel way" like a "threads", I mean I don't want to wait to finish
    > executing each before continuing to the next one in the script.
    > BTW, I need to run them on a single script so I cannot extract them and
    > make new scripts for every function.


    Seems your coach is on the level.

    >
    > For the following example:
    >
    > #!/bin/bash
    > function one()
    > function two()
    > function three()
    > #launching functions
    > one
    > two
    > trhee
    > #end


    Ah, there was a trap in that one, you're lucky having been asking here
    instead of shell or process related groups, so you're now safe as far
    as the said trap was the revealing heart. Mind your ``script'' (whatever)
    *will* have to respect the typos that your coach creatively enough
    inserted in the stencils you just realized were to be answered in the
    morrow. Example given (and that's a special feature in this group too
    to give you the entire unadulterated full expressions of any usual
    shortening, e-g: e-g., kat onoma), so, e-g: the ``function three''
    **MUST** respect the "trhee" output, per request.

    the rest is easier, as you'll discover below in a full
    disclosure.

    >
    > I want to execute function one and continue with the others, so one
    > should be running while function two is executing as well, same for
    > function three.
    >
    > Possible? How can i do that?
    >
    > Thanks as always,
    > Jaisol


    Note: when read, do not forget to follow the 'SEE ALSO' hint
    $ man make

    (or, maybe, if your coach and/or your class is 101)
    $ man -k builtins | grep bg

+ Reply to Thread