LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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, 10: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, 12:40 PM   #2
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 637

Rep: Reputation: 248Reputation: 248Reputation: 248
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 12:50 PM.
 
Old 12-08-2014, 02: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, 04:33 PM   #4
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 637

Rep: Reputation: 248Reputation: 248Reputation: 248
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 07:30 AM
[SOLVED] Working awk script doesn't work in Debian Perseus Programming 14 10-22-2012 02:36 PM
Problems with storing oracle sqlplus query output shell script rockf1bull Red Hat 0 12-04-2011 11:47 AM
execute oracle procedure from linux script and sqlplus Stilltray Linux - Newbie 3 11-14-2008 10:35 AM
Oracle SQLPlus Help StupidNewbie Programming 2 08-18-2008 02:48 PM


All times are GMT -5. The time now is 03:53 AM.

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