how to enter prompt input through shell script -


i have shell script (main.sh) in first few lines read data through user's input.

    echo   "enter model  !!"     read model     echo "enter weight !!"     read wgt     echo  "enter data file  !!"     read datafile     echo  "enter 2 column names  !!"     read coll1 coll2 

these variables $model, $wgt, $datafile, $coll1, $coll2 being used in rest of programs. when run ./main.sh , give inputs respectively model, wgt, data, col1 col2, running fine. want give these inputs through file. created script file contains

    echo "col1 col2" | echo "data" | echo "wgt" | echo "model" | ./main.sh 

its taking first input i.e. model. there way correctly?

don't pipe echo echo. echo doesn't read standard input , losing last one. if worked written backwards.

you want more this:

{     echo "model"     echo "wgt"     echo "data"     echo "col1 col2" } | ./main.sh 

which, of course, be:

printf 'model wgt data col1 col2 ' | ./main.sh 

Comments

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -