3
Contributors
5
Replies
6
Views
9 Years
Discussion Span
Last Post by arjayes
0

One way to do it, also assuming know how many instances of it you want to run, is in a loop, start the process in the background.

while (x < counter){
  ./process&
  x++;
}
0

One way to do it, also assuming know how many instances of it you want to run, is in a loop, start the process in the background.

while (x < counter){
  ./process&
  x++;
}

thanks for that
but the code is giving an error

./runall.sh: line 7: syntax error: unexpected end of file

the actual code being in file runall.sh the counter is 100(ie. 100 instances of the compiled code

#!/bin/bash
while (x < 101)
        {
          ./<filename> &
           x++;
        }

i am a beginner to shell scripting so please bear with me

0

The while loop was pseudocode to give you an idea of what you might need. I am sorry if I confused you.

Check out this tutorial, that tells you how to do loops in bash scripting.

0

Change this

#!/bin/bash
while (x < 101)
        {
          ./<filename> &
           x++;
}

To this and you should be good

#!/bin/bash

x=1
while [ $x -lt 101]
do
          ./filename &
           let x=$x+1
done

The bash tutorial referenced in a previous post is a good read if you're going to be doing this a lot. There are more succinct ways of getting this done using bash's built-ins, but, I'm an old dog ;)

Best wishes,

, Mike

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.