I need to run a Fortran(90) program with different parameters. The Fortran program in interactive, and receives several input parameters sequentially (it asks for each parameter individually, i.e. they are read in at different instances).
My idea is to write a short bash script to change the pertinent parameters and do the job automatically. From the command line the following works fine:
./program <<< $'parameter1
parameter2
parameter3'
When trying to change the parameters in a bash script, things stop working. My script is as follows:
#!inash
parameter1=1
parameter2=2
parameter3=3
inputstr=$parameter1'
'$parameter2'
'$parameter3
./program <<< $inputstr
The input string ($inputstr
) is the correct string ('parameter1
parameter2
parameter3'
), but is interpreted as a whole by bash, i.e. it is not given as three independent parameters to the Fortran program (the whole string is interpreted as parameter1).
I have tried several ways of putting inputstring
within brackets, apostrophes or other, but none seems to work.
Is there a way to make this work in a automated manner?
question from:
https://stackoverflow.com/questions/65939169/multiple-fortran-arguments-in-bash-script 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…