1

I'm kinda new in bash, the thing is I need to run several set of data in a program, I make a bash script that allow me to do it automatically... the problem is when the program start it needs some inputs and I don't know how to give it inside the bash? I execute the program:

$./bin/mg5_aMC

The program opens and I need to pass some input to run (mg5> is the enviroment of the program):

mg5>launch file.lhe

the program runs, and ask for something:

mg5> 1

and then again, ask for something and i need to press enter..

mg5> (enter)

PD.: I edited the question because I suppose didn't express myself very well..

isk27
  • 329
  • 2
  • 5
  • 13

3 Answers3

1

From what I understood from your question, you either want 1) to pass parameters when calling your Bash script, or 2) some sort of interactive shell within your script.

For #1, passing parameters to a Bash script, these links may be helpful:

Basically, you need to use the following call for your script:

./bin/mg5_aMC launch xxx.lhe 1

And within your script, you refer to each argument using a numbered variable:

action=$1
file=$2
n=$3

As for #2, consult the following links/examples:

There are quite a few resources online and on this site that will provide you more example and explanations.

Community
  • 1
  • 1
InfectedPacket
  • 264
  • 2
  • 8
0

If the program can get its input as arguments passed from the command line, then you can write the parameters in a file, call it e.g. params, then do

./bin/mg5_aMC $(<params)
vsoftco
  • 55,410
  • 12
  • 139
  • 252
0

From what I see, you rather want to catch user's input, than simply pass args to executed script. read command allows you to catch user's input. Did it answers your question?

grimsock
  • 774
  • 5
  • 18