0

I have a program dnapars I execute the program from command line as following: ./dnapars The program then prompts me some message as a user menu from where I have to select a series of options in the order R U Y R. And then I copy the output file (outfile) in another result file. I wrote the following script, but the execution hangs where it is supposed to execute the R option

for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
do
cp ../../../EditDistanceRandomParsimonator/RAxML_parsimonyTree.test4D20RI$i.0 intree
./dnapars
R      <----- This doesn't execute
U
Y
R
cp outfile result$i
done

How can I make the script to run the options R U Y R under the dnapars program ?

1
  • Can you not provide arguments to dnapars to control it? If not, do you have the source? If so, add argument parsing. If not, can you go back to the author and request it? Now you know why people don't always like interactive programs like that. One option if you need interactive input is to have an interactive program prompt for the information needed and then pass that information to the non-interactive program so that you don't always have to interact with the main computational code. This works well for many, but not all, programs. Commented Jan 2, 2012 at 4:49

1 Answer 1

1

You may be able to use a shell here document, for example:

./dnapars <<EndOfOptions
R
U
Y
R
EndOfOptions

This will generally work if the program reads its options from stdin.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.