Running SQL*Plus with bash causes wrong encoding

Posted by Petr Mensik on Server Fault See other posts from Server Fault or by Petr Mensik
Published on 2012-03-15T08:35:01Z Indexed on 2012/12/10 17:06 UTC
Read the original article Hit count: 476

Filed under:
|
|
|

I have a problem with running SQL*Plus in the bash. Here is my code

#!/bin/bash

#curl http://192.168.168.165:8080/api_test/xsql/f_exp_order_1016.xsql > script.sql
wget -O script.sql 192.168.168.165:8080/api_test/xsql/f_exp_order_1016.xsql
set NLS_LANG=_.UTF8
sqlplus /nolog << ENDL
connect login/password 
set sqlblanklines on
start script.sql
exit
<<endl

I download the insert statements from our intranet, put it into sql file and run it through SQL*Plus. This is working fine. My problem is that when I save the file script.sql my encoding goes wrong. All special characters(like íášc) are broken and that's causing inserting wrong characters into my DB. Encoding of that file is UTF-8, also UTF-8 is set on the XSQL page on our intranet. So I really don't know where could be a problem.

And also any advices regarding to my script are welcomed, I am total newbie in Linux scripting:-)

© Server Fault or respective owner

Related posts about linux

Related posts about bash