Passing a string variable from Unix to Sql Plus

Hi Guys,

I am trying to pass a string variable from Unix shell script to sqlplus as a parameter.

I have tried using single quotes with the variable name but it does not work. Please help me with it.

I am using BASH.

My code:

Your help is much appreciated.

Thanks,
shil

Does the script threw any error..? If so please post the same. And there is a semicolon miss in your code exit;
Below is a sample code to login to sqlplus and querying by passing a parameter

#!/bin/bash
line=sysdate
cnt=2

sqlplus -s user_t/user_t@ORADEV <<EOF > $(echo $PWD)/outfile.txt
select $line from dual;
select * from emp where emp_id='$cnt';
exit;
EOF

The mistake I did was:

I created the text file (table_list.txt) from windows. Now I created from UNIX and it works.

The simple mistake costed me a day. :frowning:

Thanks for all your help.