marchello
Posts: 81
Joined: Fri Oct 11, 2013 8:59 am

linux + oracle + sqlplus + awk, script doesn't work

Mon Dec 08, 2014 4:33 pm

Hi all,

We get log_id value empty after migration.

Code: Select all

log_id=$(sqlplus -s /nolog <<-EOF|awk 'NR==2 {print $1}'
  set head off
  set feed off
  set pagesize 0
  conn $DBCONN_AUDIT
  select pls_audit.get_id_log from dual;
#EOF)
Maybe (I'm not sure) the problem is in awk.
Last time http://www.raspberrypi.org/forums/viewt ... 31&t=93044 we had problem with

Code: Select all

awk -F\t
and changed it to

Code: Select all

awk '-F\t'
(works great).

Please someone comment is it problem in awk syntaxis and how to solve.
Thanks ahead.

marchello
Posts: 81
Joined: Fri Oct 11, 2013 8:59 am

Re: linux + oracle + sqlplus + awk, script doesn't work

Mon Dec 08, 2014 8:27 pm

This way it works fine:

Code: Select all

echo -e "conn user1/pass1@plspro\nselect pls_audit.get_id_log from dual;" | sqlplus -s /nolog

GET_ID_LOG
----------
  33363309
So I guess it is not Oracle question, it is more linux question about syntaxis...

Maybe someone can kindly help please?

Return to “General programming discussion”