I have two scripts. One is named sqlscript.sql and the other is named script.sh I have all of the queries needed written in my sql script. They are just a bunch of update statements. For example:
UPDATE xxDev.SYS_PARAMS SET val = 'serverName' WHERE lower(name) = 'enginebaseurl';
I'm running the .sql script IN the .sh script. When the .sh script runs, I want it to prompt the user for a server name and take that user input and replace it in serverName in the sql statements.
I'm brand new to both bash scripting and this website, so I hope I'm making sense asking this question. I'm using PuTTY if that makes a difference at all.
I would probably use a variable
You can split the
sqlscript.sqlintoset-val.sql
and the actual update statements. Then you can recreate the
set-val.sqlfrom your user input:and then you forward both files to mysql:
You should probably use this only for internal things, it seems a little fragile.