| Unix Content | Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
|
| 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
|
| jaisol > 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
|
| On Fri, 22 Aug 2008 13:09:59 -0700 (PDT), jaisol >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
|
| 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
|
| 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 |