Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
04-27-2010, 12:22 AM
|
#1
|
|
LQ Newbie
Registered: Apr 2010
Posts: 3
Rep:
|
How to control execution of programs in a shell script.
Dear LinuxQuestions,
Do you know how to write a shell script that executes say 4 instances of the same program in different directories at the same time, and once ONE instance completes it executes a new instance of that program in a new directory, and so on, until 100 instances have been executed, each in their own directory.
Cheers,
Chrisantha
|
|
|
|
|
Click here to see the post LQ members have rated as the most helpful post in this thread.
|
04-27-2010, 12:49 AM
|
#2
|
|
Guru
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 6,316
|
Maybe if you gave us an example we may be able to assist?
|
|
|
|
04-27-2010, 01:07 AM
|
#3
|
|
LQ Newbie
Registered: Apr 2010
Posts: 3
Original Poster
Rep:
|
I'm basically wanting to run several versions of a C++ genetic algorithm in Mac OS X. I want to run a batch of these programs on a server that has 5 nodes, and I want to start a new program each time one of the previous programs ends.
It seems this must consist of 3 parts.
1. Regular checking to see if a program has ended
2. Starting a program conditional upon this.
3. Making sure it starts in its own directory.
Basically, I have not done any sophisticated shell programming before.
Cheers,
Chrisantha
|
|
|
|
04-27-2010, 10:15 AM
|
#4
|
|
Senior Member
Registered: Nov 2005
Distribution: Debian
Posts: 2,017
|
Quote:
|
Basically, I have not done any sophisticated shell programming before.
|
Sophisticated shell programming is a bad idea.
Code:
#!/bin/sh
seq --format 'dirname%g' 100 | xargs --max-args=1 --max-procs=4 ./gene.sh
gene.sh:
Code:
#!/bin/sh
DIR="$1"
mkdir "$DIR"
cd "$DIR" || exit 1
/path/to/your/program
|
|
|
2 members found this post helpful.
|
04-28-2010, 02:45 AM
|
#5
|
|
Senior Member
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,211
Rep: 
|
Quote:
Originally Posted by ntubski
Sophisticated shell programming is a bad idea.
|
never a truer word spoken.
they can be horrendous.
|
|
|
|
04-28-2010, 03:29 AM
|
#6
|
|
LQ Newbie
Registered: Apr 2010
Posts: 3
Original Poster
Rep:
|
Thanks
Thank you I shall examine this and learn.
Chrisantha
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:09 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|