looping and saving output of each line separately

I have been trying this program for a long time. I am trying to read a file named "odon" line by line; read the first line, send it to do a command saved in a file "perm", once the first line has finished going through the content of the file perm, the result is saved with the number of the line. Once that is done, the script reads the second line and repeats the process until all the lines have been read, sent to the other file and the output saved. This is what I mean:

12 1 1
2 1 1
3 1 1
92 1 1

read line 12 1 1, send it into file "perm" which contains a command, then the output is saved as beta. The next file as beta1, the next file as beta2 etc. The content of perm will output "beta" when it is read in the right way. I used only one 12 1 1 and it gave me beta, but to read each line and save with different names is proving difficult.
This is what I have done so far:

#!/bin/sh
for i in 'cat odon'
do echo $i | ./perm $i > $i
cp beta beta.$i
done  

This does not seem to work as I want. I would appreciate your contribution. Thanks

What's in perm ? Does it read from a pipe, or does it take a parameter? In the script as posted, it does both.

perm contains a program that runs automatically if done right. t contains something like itgen -m 500 -r rhs -b beta -n con.
I want each line to pass through perm and send out beta. The next line should be beta1 etc. I have tried it for just one line and it gave me beta
Thanks

It is impossible to guess what faulty script is intended to do. I repeat:

perm is a file name I just created and it contains a program whichI want each line to be read into. I just tried to pipe each line to perm. It may not be the right approach to take. The content of perm which automatically produce an output beta for one line of the file odon. My challenge here is to do each line automatically instead of having to manually work through each line

Whether it's the right approach or not really depends on what perm does. It might be the right approach. It might not. We literally have no idea.

Until you explain what perm actually does -- the input you feed into it and the output you expect from it -- we can't help you.

I just created a file and named it perm. It is the content of the file that is important because it contains a program we use in research. The program is: itgen -m 500 -r rhs -b beta -n con (I just created the file to save what I need). Its like doing a*b=c, the the program gets the value of b for you automatically. Each line must pass through this program and it will output b which in my case is beta. That means I have a file named rhs and another named con; but itgen -m 500 -r rhs -b beta -n con will run through each of this files by itself so I don't really need to bother about the files. The first line in the file odon (12 1 1) will pass through itgen -m 500 -r rhs -b beta -n con and beta will be automatically produced (I have tried it with just one line and it gave me beta so it works). My challenge is to take the first line and put it in the file I save as perm, produce beta, then repeat it for each line in odon saving beta as beta0, beta1 etc

:wall:

We cannot guess what it's doing until you actually show us, especially when your program and your explanation appear to contradict each other.

Show us -- word for word, letter for letter, keystroke for keystroke -- how you'd run that program manually, to input one value, and get one result back. Use screenshots if you have to, but we need to see how it's used. It's not enough to know that it "can work" somehow, when all you've given us is a program which doesn't.

The separate script called perm adds an unwanted level of complexity to the main script because we now have to pass parameters to the other script and receive the results.
This is one of those posts where we would rather see the the problem than the solution.
In UK we have a saying, KISS.

I don't know what you mean by the UK comment but I hope it is not derogatory. The most important thing which is what I need to run is the itgen............I created perm just to save that program. This is an animal breeder's took kit that is preprogrammed to run that way. what it does is to iterate for 500 rounds-r rhs is the name of the file on the right hand side, -n con is another file and -b beta is the answer I am looking for. It is like this conbeta=rhs therefore, beta=con-1rhs. So each line in file odon will pass through this program and beta will be produced. Unless I can create a script that can produce beta for each line and save it like beta0, beta1 etc, then I will have to manually do it myself. This is the script I tried for just one line:
while read line
do ./perm
done < odon #note that the file odon has one line 12 1 1 so only beta for the line will be produced

(KISS = Keep it Simple)

Ps. I'll leave you to work out how to use code tags and how to lay out a post so that non-specialists in your field can understand the post. No offence intended, but when I last looked post #10 was too difficult to understand.

You've given a third explanation now; partially contradicting the other two before it. I'm less sure which of your three partial explanations to believe than ever.

Don't tell us how it's used in words, just show us what keys you hit and what the program puts back out to terminal and/or file. Show a working example of you using it once, not in a loop, with one value. Show what you type in. Show what you get out.

Show us how you'd run that program manually, putting one value in, getting one value out. Use screenshots if you have to, but show us!.

Don't show us a script which doesn't do what you want. Obviously that won't tell us what you do want -- it's wrong, but in what way is it wrong? We can't know the way to run it successfully without seeing you run the program successfully.

If I knew what to do, don't you think I would have done it? That's why I am asking for input, I am about 1 month into programing. Thanks

I am not asking you to write the script.

You apparently know how to use this 'perm' program for single items but don't know how to put it in a loop.

We don't know how to run this program yet, not even for single items. All we have is your broken loop which doesn't work. We can't guess which of 10,000 possible variations of parameters and piping 'perm' actually expects, and your explanations seem a bit muddled.

I am asking you to run 'perm' in your terminal once, cat its output files if any, hit your 'print screen' key, and attach the screenshot. That will unambiguously show how your program is used on a single item, and we can build a loop around it from there.

it is the actual beta for line one that I am working on

Does your loop -- whatever it is -- actually work, or is it another broken one? What's "sire", and why are you feeding it into the loop? What is the purpose of the loop? What output does this produce, if any?

Most of what you actually did in that terminal, i.e. the parts I actually asked for, are obscured behind your browser window. Come on. We're trying to help you. Work with us a little. :wall:

try this

#!/bin/sh
var=1
while read i 
do
  echo $i | ./perm $i > $i  (check this as i dont know what perm is doing)
  cp beta beta$var
  var=$(expr $var + 1)
done < yourfilename