On Mon, Oct 31, 2011 at 6:14 PM, Fernan Aguero <fernan.agu...@gmail.com> wrote: > Hi, > > please accept my apologies, as this is my first post here. I'm sure > I'm asking a very stupid questions, but I'm kind of stuck with this > ... > > The Problem: a badly written C program (mktrace) that doesn't accept > input as usual. > > E.g. you cannot do this: 'mktrace filename', nor this 'mktrace < filename' > > Instead, you have to run it like this: > > [fernan@host] mktrace > warning: this program uses gets(), which is unsafe. > enter FASTA filename: (type filename here) > enter output filename: (type another filename here) > > which of course does not make it easy when you have to run mktrace on > 1000 files. > > > I've started playing with bash, trying to work around this, with mixed > success: > > This doesn't work: > #!/bin/bash > mktrace > echo "filename" > echo "output" > > Nor this: > #!/bin/bash > mktrace | { > echo "filename" > echo "output" > } > > However, this kind of works (though I don't quite understand why): > #!/bin/bash > find . -type f -name '*.fasta' | { > while read f > do > mktrace > echo "$f" > echo "$f.ab1" > done > } > > > In this latter case, my script gets mktrace to do its magic, BUT: > > i) only for one file in the directory (there are many files that match > the globbing pattern) > ii) it overwrites the original .fasta file with the expected binary > output, and generates a new file (*.phd.1), as expected. > > [Note: in addition to the output filename specified, mktrace generates > another output file, with the same namebase but ending in '.phd.1'] > > Any idea or suggestion would be much appreciated. I'm particularly > interested in understanding and learning along the way :) > > Cheers, > > -- > fernan > >
You should probably use expect instead of trying to get Bash to do it. -- Visit serverfault.com to get your system administration questions answered.