Bash script to start program and answer prompts?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash script to start program and answer prompts?
# 1  
Old 06-12-2012
Bash script to start program and answer prompts?

I'm trying to write a script the simplifies the execution of a program:

After starting the program (sh ~/.mfix/model/make_mfix) I am prompted four times for options:
Do you need SMP version? (y/n) [no]
Do you need DMP version? (y/n) [no]
Do you need debug version? (y/n) [no]
Force re-compilation of source files in run directory? (y/n) [no]

If I don't use the script, I simply hit the enter key four times (because the default setting is correct). After that, I am prompted once more:

Select the compiler to compile MFIX? [1]

This time I'd actually like to change the value to 11 (because the default setting is incorrect), followed by a return.

My poor attempt can be seen below:
Code:
#!/bin/bash
sh ~/.mfix/model/make_mfix




echo 11

I have no idea how to script "returns," or if it's even possible given that the script probably doesn't want to continue until the first line has been fully executed.

Any ideas guys? Any recommendations would be greatly appreciated!
# 2  
Old 06-12-2012
This might work:
Code:
echo -e "\n\n\n\n11\n" | sh ~/.mfix/model/make_mfix

# 3  
Old 06-12-2012
Thank You!

Bartus, you are the man! That worked better than I could have expected. Flawless. Thank you very much.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Putting bash script in C program

suppose i have a bash script: #!/bin/bash echo "hello" echo "how are you" echo "today" how can i put the entire script above into a basic c program? i do not want to translate the bash code to a c code. i want C to run the bash code. is this possible? i found this on the... (15 Replies)
Discussion started by: SkySmart
15 Replies

2. Shell Programming and Scripting

Scrolling through text while interacting with program prompts

Hi all, I am trying write a shell script to automate the installation of a program, but during the process of the installation, the installation program requires the user to scroll through 10 pages of a license agreement. Since this is coming from stdout and is not a prompt, I am unable to send... (4 Replies)
Discussion started by: nanlee
4 Replies

3. Shell Programming and Scripting

Problem with bash shell script program

Hi, This is my program. #!/bin/bash today=`date +"%b-%d-%Y"` SERVICE="pbxconnect.php" if ; then echo "pbx program is running" else nohup php pbxconnect.php > logpbx-$today.txt & fi On executing using "sh myprogram.sh" , i get the following error. myprogram.sh: line 4: ' My... (7 Replies)
Discussion started by: gskumar1234
7 Replies

4. Homework & Coursework Questions

Run Program from Bash CGI-Script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: This is a problem I am having with my 2 semester senior project. I have a LAMP server running Ubuntu 9.10 with... (8 Replies)
Discussion started by: JMooney5115
8 Replies

5. Emergency UNIX and Linux Support

Bash answer prompt

I am working with a script to simplyfy some operations where I work, but one of the programs needs me to enter a password. It will as me "Please enter the administrator password:" Is there a way to make a bash script to automatically answer the question with the needed password? I am looking... (3 Replies)
Discussion started by: noratx
3 Replies

6. Shell Programming and Scripting

Start program in background (or start crontab ahead of time)

Hey! I'm working on a script that will add a user, create some configfiles, and add a crontab for the user. The crontab looks like the following: @reboot /home/user/program config.conf & I would like for this process to start at the end of my script under the corresponding username by... (0 Replies)
Discussion started by: noratx
0 Replies

7. Shell Programming and Scripting

Shell Program that prompts for user Id

Hi I have a question that after trying tirelessly I cant solve. I'm not great wth UNIX and wonder if anyone could help. I have to create a shell program using functions that prompts for a user ID. I must then verify that the user Id corresponds to an account on the system. If a legal user Id is... (16 Replies)
Discussion started by: mmg2711
16 Replies

8. UNIX for Dummies Questions & Answers

Shell Program that prompts for user Id

Hi I have a question that after trying tirelessly I cant solve. I'm not great wth UNIX and wonder if anyone could help. I have to create a shell program using functions that prompts for a user ID. I must then verify that the user Id corresponds to an account on the system. If a legal user Id is... (1 Reply)
Discussion started by: mmg2711
1 Replies

9. Shell Programming and Scripting

Shell script answer prompts?

Hi, I'm writing a script that calls a function to generate a certificate. In generating this certificate, I'm asked a series of questions. I was wondering, is there a way to pre-program my script to answer these questions in the same way all the time. I saw something like EOF>> y EOF ... (4 Replies)
Discussion started by: eltinator
4 Replies

10. UNIX for Dummies Questions & Answers

How do I start a program when I start my Computer?

I'm running MAC OS X and I'm wondering how I start 'nixey programs (not normal apps) on startup? Things like the dnet client and hxd Hotline Server. Anyone know? (1 Reply)
Discussion started by: l008com
1 Replies
Login or Register to Ask a Question