Running binnary program in a loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Running binnary program in a loop
# 1  
Old 02-12-2011
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:
Code:
#!/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 loop, something like this:
Code:
#!/bin/bash
#!/bin/bash
for i in {1..n}
do
    mv block${i} infile
    ./dnadist <<EOF
    D
    Y
    EOF
done

But, of course is wrong and I only get this error:
Quote:
./MUS: line 17: warning: here-document at line 5 delimited by end-of-file (wanted `EOF')
./MUS: line 18: syntax error: unexpected end of file
I will be very thankful if some one can point me in the right direction.
Thanks!
# 2  
Old 02-12-2011
Hi
Try this:

Code:
#!/bin/bash
#!/bin/bash
for i in {1..n}
do
    mv block${i} infile
    ./dnadist <<EOF
D
Y
EOF
done

I just removed the alignment.

Guru.
# 3  
Old 02-12-2011

Put the closing EOF at the beginning of the line, or, if it is preceded by a tab, add - before the first EOF:
Code:
	./dnadist <<-EOF
	D
	Y
	EOF

# 4  
Old 02-12-2011
Great!

Please bear with me! If I do the following, would that work?

Code:
#!/bin/bash
for i in {1..2}
do
    mv block${i} infile
    ./dnadist <<EOF
D
Y
EOF
    rm infile
    mv outfile infile${1}
done

OR
Code:
#!/bin/bash
for i in {1..2}
do
    mv block${i} infile
    ./dnadist <<-EOF
    D
    Y
    EOF
    rm infile
    mv outfile infile${1}
done

Thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How to keep program running after logout

Hello everyone. I am logged into a computer through ssh. I would like to run a program and have it keep running after I log out without screen (i forgot to run it). For example: ssh server user/comp~$ top & 12021 exit after that: ssh server user/comp~$ (something, maybe shell... (5 Replies)
Discussion started by: lepetal
5 Replies

2. Shell Programming and Scripting

Running C# program problem

Hi All, How to run c# program using shell script ? (1 Reply)
Discussion started by: srikar.ch
1 Replies

3. Shell Programming and Scripting

Help with Running More than One Program

Folks, I'm really new to scripting and was wondering if you could help me out. I have the following script that I inherited: #!/bin/bash # # Usage # From the agent directory: # ./run-any-agent AgentName # TAC_AGENT_HOME=`pwd` LIB=${TAC_AGENT_HOME}/lib CLASSPATH=.... (17 Replies)
Discussion started by: DTriniWay
17 Replies

4. Shell Programming and Scripting

Kill the running program

Dear All, I have a script which after executing is not stoping when i press ctrl+c. Now i want to Append the script in such a way when i press ctrl+c while execution of the program it should take it as arguements and should kill the script/running program forcefully. I know the command to... (1 Reply)
Discussion started by: akhtar.bhat
1 Replies

5. Programming

running a parallel program

hi , i need to run a parallel program . for example; program1 { array=" the second program should called here : program 2" the execution should continue } the 2nd program should recieve an array of information as argument and it should... (4 Replies)
Discussion started by: bankpro
4 Replies

6. Programming

running a program for a specified time

how can i run a program for a specified time? i need to print a current time during program execution. (3 Replies)
Discussion started by: prosputko
3 Replies

7. UNIX for Dummies Questions & Answers

Running a program on boot!

Hi there! I tried to search for something like this here but couldn't find anything. I need to run a specific program when linux starts up. I need to run it after the rp-pppoe has started because this prog needs internet connection. I start the program by entering ./dynix start (its in my home... (4 Replies)
Discussion started by: D-Lexy
4 Replies

8. UNIX for Dummies Questions & Answers

Running a program

Hi.Iam new to Linux.i got linux 7.0 pro and dont know how to run programs. I want a perl interputer and i know i installed one but how do i run it ??? Also how do i run a C or C++ editor ?and how do i run cron ? (3 Replies)
Discussion started by: perleo
3 Replies

9. Programming

running a c/c++ program in unix

This is not a question, but rather a simple how-to for programmers who are new to the UNIX environment. I too,am new to UNIX. First I developed a few programs on my box and perfected them until they were satisfactory for execution. Problem was however, that once i compiled and all that,... (2 Replies)
Discussion started by: kray
2 Replies

10. Programming

Running a compiled Program

Just getting into the Unix command line programming and am unable to run any program I write. I am using a Makefile and the source is compiling but when I enter the name of the output file I get back: bash: lab01exe.out: command not found I'm sure I am just dooing something simple... (2 Replies)
Discussion started by: Krebsbac
2 Replies
Login or Register to Ask a Question