473,326 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

bash script to run program N times

6
wasn't sure what forum to put this in, but I'm sure someone here can help me.

I have a program that I want to run N times. I'd like to make a bash script that, when run like this:

./script.sh 5

will run my program 5 times, where my program can be run like this:

./myprogram

Basically I just need a loop that will execute my program, then iterate when the execution exits.

Any tips?
Sep 22 '09 #1
2 11572
sumittyagi
202 Expert 100+
use for loop construct, or while loop construct.. whichever you like.

Google -> using loops in shell script

Hope this helps

Best Regards,
Sumit.
Sep 23 '09 #2
vl4kn0
5
Expand|Select|Wrap|Line Numbers
  1. #!/bin/bash
  2.  
  3. for i in `seq 1 $1`; do
  4.         ./myprogram
  5. done
  6.  
Oct 3 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Phil Powell | last post by:
I'm sorry but I can't figure out how to explain this any better than this. In PHP we have a command "require()" that obtains a file and logically places it into another file. I cannot figure...
2
by: SimonC | last post by:
A couple of questions: (1) I have some PHP code that may take a while to execute - say 30-45 seconds or more - and I'm concerned that a browser may give up, and report an error because a page is...
1
by: Gonzalo Aguirre | last post by:
hi.. as i write on the topic, i'm programing a Bash script using the standard GNU Linux text utilities (gawk, grep, sed, and so on) that get information from SQL source (table attib, type per...
1
by: alexxxprog | last post by:
Thank you very much for who can solve this bash script: "Create on the filesystem a bash proceedure createdata that creates collections that that will have to contain a variable, a random number,...
1
by: pnjbi | last post by:
Hi, I've created a bash script which is executed every 5 minutes through a cron. The script checks if a trigger variable has been set to execute certain commands. If it is the commands are...
3
by: Gros Bedo | last post by:
Hello :-) I have a question about Python and Linux shell. I have a python program which is permanently resident in the end-user system. I'm currently producing a RPM package, and it works nicely....
1
by: Gros Bedo | last post by:
Yes I've seen that each python script calls its own instance of Python. Buthow to know which is the good one in bash ? Is there a command that gets the parameters of process, so I could use grep to...
0
by: norseman | last post by:
Gros Bedo wrote: ============================== Yes. man ps explains try ps -AFL | grep then kill -9 found (check it more than twice) 1) If your script is known to hang use what...
0
by: kidko | last post by:
I've written a Zenity frontend for ffmpeg using a Bash script. However, if the user hits "cancel" in the progress dialog (incurring the --auto-kill option), the bash script is killed. Unfortunately,...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.