LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-08-2014, 11:57 AM   #1
marchelloUA
LQ Newbie
 
Registered: Nov 2014
Posts: 27

Rep: Reputation: Disabled
Question linux + oracle + sqlplus + awk, script doesn't work


Hi all,

We get log_id value empty after migration.
Code:
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.linuxquestions.org/questi...16#post5278616 we had problem with
Code:
awk -F\t
changed it to
Code:
awk '-F\t'
(works great).

Please someone comment is it problem in awk syntaxis and how to solve.
Thanks ahead.
 
Old 12-08-2014, 01:40 PM   #2
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 701

Rep: Reputation: 285Reputation: 285Reputation: 285
Edit: Disregard. Sorry, misunderstood your question.


From the bash man page:
Quote:
A non-quoted backslash (\) is the escape character. It preserves the literal value of
the next character that follows, with the exception of <newline>.
So using -F\t would split the line on the letter t. You can use -F'\t' or -F\\t

BTW I agree with grail's statement in your other thread about quoting -F.

Last edited by norobro; 12-08-2014 at 01:50 PM.
 
Old 12-08-2014, 03:33 PM   #3
marchelloUA
LQ Newbie
 
Registered: Nov 2014
Posts: 27

Original Poster
Rep: Reputation: Disabled
Question

This way it works fine:
Code:
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?
 
Old 12-08-2014, 05:33 PM   #4
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 701

Rep: Reputation: 285Reputation: 285Reputation: 285
Have you tried echoing $log_id without the pipe to awk to see what it contains?

In the output that you posted, it looks like the id number is the fourth record (NR==4).
 
  


Reply

Tags
awk


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing Multiple shell variables to awk script doesn't work ripudaman.singh Programming 3 08-27-2014 08:30 AM
[SOLVED] Working awk script doesn't work in Debian Perseus Programming 14 10-22-2012 03:36 PM
Problems with storing oracle sqlplus query output shell script rockf1bull Red Hat 0 12-04-2011 12:47 PM
execute oracle procedure from linux script and sqlplus Stilltray Linux - Newbie 3 11-14-2008 11:35 AM
Oracle SQLPlus Help StupidNewbie Programming 2 08-18-2008 03:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration