User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 456,442 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,610 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 744 | Replies: 5
Reply
Join Date: Dec 2007
Posts: 3
Reputation: arjayes is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
arjayes arjayes is offline Offline
Newbie Poster

Please help

  #1  
Dec 4th, 2007
I need a shell script to simultaneously run multiple instances of a compiled c code
can some one please help i'm using BASH
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2007
Posts: 302
Reputation: stilllearning has a spectacular aura about stilllearning has a spectacular aura about 
Rep Power: 3
Solved Threads: 37
stilllearning stilllearning is offline Offline
Posting Whiz

Re: Please help

  #2  
Dec 4th, 2007
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++;
}
Last edited by stilllearning : Dec 4th, 2007 at 10:57 am.
Reply With Quote  
Join Date: Dec 2007
Posts: 3
Reputation: arjayes is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
arjayes arjayes is offline Offline
Newbie Poster

Re: Please help

  #3  
Dec 4th, 2007
Originally Posted by stilllearning View Post
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
Reply With Quote  
Join Date: Oct 2007
Posts: 302
Reputation: stilllearning has a spectacular aura about stilllearning has a spectacular aura about 
Rep Power: 3
Solved Threads: 37
stilllearning stilllearning is offline Offline
Posting Whiz

Re: Please help

  #4  
Dec 4th, 2007
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.
Last edited by stilllearning : Dec 4th, 2007 at 12:29 pm.
Reply With Quote  
Join Date: Oct 2007
Posts: 306
Reputation: eggi is on a distinguished road 
Rep Power: 2
Solved Threads: 29
eggi eggi is offline Offline
Posting Whiz

Re: Please help

  #5  
Dec 4th, 2007
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
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
Reply With Quote  
Join Date: Dec 2007
Posts: 3
Reputation: arjayes is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
arjayes arjayes is offline Offline
Newbie Poster

Re: Please help

  #6  
Dec 5th, 2007
Thanks for that
It worked perfectly
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Shell Scripting Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 1:44 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC