unix - How to store result from SQLPlus to a shell variable -


my requirement store result of sqlplus operation variable in shell script. need result of following operation in .sh file

sqlplus 'user/pwd' @test.sql 

i have tried

testvar = 'sqlplus 'user/pwd' @test.sql' 

but doesn't work.

edit::

i changed to

testvar=sqlplus foo/bar@schm @test.sql 

and says

sql*plus:: not found [no such file or directory]

i tried

testvar=$(sqlplus foo/bar@schm @test.sql) 

and gives same error. when try without variable assignment below

sqlplus foo/bar@schm @test.sql 

it works fine

employ backticks:

testvar=`sqlplus foo/bar @test.sql` 

or should of syntactical eyesore:

testvar=$(sqlplus foo/bar @test.sql) 

you know take right sql*plus commands limit superfluous output, yes? :) , of course beware backticking collapse whitespace of output.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -