Invoking a program in a loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Invoking a program in a loop
# 1  
Old 11-29-2010
Invoking a program in a loop

In the following script, I wish to invoke a compiled C++ program, consimv4 and pass it some command line arguments through the shell script's command line arguments and variables. But for some reason, when I run the script, I just return to the shell prompt and nothing happens. For the life of me, I can't locate what syntax error I am committing. Could someone point out my error, please? I am running bash.
Code:
ants=3
l_max=1000
init_pher=20
ef=0.8
beta=30
iter=1
qo=0.3
for (( i = $1 ; i <= $2 ; i++ ))
do
 `./consimv4 rbdatacsimNov1.txt 0 $i 1 0 a ants $ants l_max $l_max init_pher $init_pher ef $ef beta $beta iter $iter q0 $q0`
done


Last edited by Scott; 11-29-2010 at 03:02 AM.. Reason: Please use code tags
# 2  
Old 11-29-2010
Why the backticks? I would get rid of them and see what happens.
# 3  
Old 11-29-2010
Sure. In that case, the variable values aren't passed to the consimv4 program. It throws a segmentation fault with the following command line:

./consimv4 rbdatacsimNov1.txt 0 $i 1 0 a ants $ants ......

As you can see the variable value substitution isn't taking place.
# 4  
Old 11-29-2010
What is the shell that you use for your script?
# 5  
Old 11-29-2010
/bin/bash
# 6  
Old 11-29-2010
Are you sure there isnt a problem with the C++ app? What happens when you try this from the command line:

Code:
  ./consimv4 rbdatacsimNov1.txt 0 0 1 0 a ants 3 l_max 1000 init_pher 20 ef 0.8 beta 30 iter 1 q0 0.3 done

Keep replacing the second 0 and count up until you reach whatver $2 is.
# 7  
Old 11-29-2010
Use set -x inside the script to see what's going on.
These 2 Users Gave Thanks to Scrutinizer For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

invoking script

hi all, is there a way to run a script upon invoking an application . for eg if i click on mozilla i want a script to run , before runniing mozilla , maybe ask a password or something only then open mozilla (2 Replies)
Discussion started by: mithun1!
2 Replies

2. UNIX for Dummies Questions & Answers

Program output in terminal by invoking in cron

Hi, I have lost a lot of hours by looking for answer but without results.. My problem is that: I use Debian GNU/Linux and I want to configure cron in order to run rtorrent every day between 24.00 and 09.00. That part I have achieved, but I couldn't forced cron to make it visible on any of my... (10 Replies)
Discussion started by: juru_piotr
10 Replies

3. UNIX for Dummies Questions & Answers

Using Shell Script To Loop Program Through Multiple Text Files

Hello, So I have approximately 300 files of raw data (.txt) files that I am using to perform statistical analysis. I have been able to construct a Fortran program that is able to perform my statistical analysis on a file by file basis. However, I now want to be able to loop program through... (19 Replies)
Discussion started by: Jimmyd24
19 Replies

4. Shell Programming and Scripting

For loop to run external program

Hi, I was hoping for help with a for loop to run a program (vina) repeatedly using all the files in a folder as input. Currently my code looks like this: #!/bin/bash FILES=/home/afalk/Desktop/battest/*.pdbqt for f in $FILES do vina --config /home/afalk/Desktop/A.txt --ligand "$f".pdbqt done... (5 Replies)
Discussion started by: oldmanwinter
5 Replies

5. Shell Programming and Scripting

Running binnary program in a loop

I am using a very simple script (MUS) to process some files where the input file for the binary application I am running has to be named infile. So I have this: #!/bin/bash for i in {1..n} do mv block${i} infile done ./dnadist <<EOF D Y EOF However, I want to use dnadist inside the... (3 Replies)
Discussion started by: Xterra
3 Replies

6. UNIX for Dummies Questions & Answers

invoking non-standard program in linux

I have a program R installed on Ubuntu under /usr/bin/R. I also have a different version installed under /home/user/R. I would like to invoke the locally installed program temporarily. How can I do this automatically by running a script and then switching to the default program? thanks, SM (2 Replies)
Discussion started by: smeme
2 Replies

7. Shell Programming and Scripting

program in loop.

eg: sample.dat 21111111110000652 B86860003OLFXXX0000001_20081227 21111111110000652 B86860003ODL-SP0000002_20081227 21111111110000652-B94030001ODL-CH0000003_20081227 22222222220000653-B94030001OLFXXX0000011_20081227 23333333330000654-E71060001OLFXXX0000012_20081227 24444444440000655... (5 Replies)
Discussion started by: kshuser
5 Replies

8. Shell Programming and Scripting

redirect variable to same program at next loop

Hi all, I don't know how to redirect a variable in this case: while true do ./ready_data ... done ready_data should read a file looking for an ID, if this doesn't exist then add the last ID seen into the first line. When ID exists there is no problem, but when ID doesn't... (0 Replies)
Discussion started by: csecnarf
0 Replies

9. UNIX for Dummies Questions & Answers

While loop program

I have a data file contain the following information: 1 2 3 4 5 10 11 30 90 300 9 29 and on and on I need to create a program with give me the following data format: Jon A (2 Replies)
Discussion started by: bobo
2 Replies

10. Programming

invoking an Unix script from a C Program

How to invoke an Unix Script from C program? (or) How to invoke another C program from a C program? thanks Karthik (5 Replies)
Discussion started by: fermisoft
5 Replies
Login or Register to Ask a Question