LinuxQuestions.org
Latest LQ Deal: Linux Power User 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 09-12-2014, 11:35 AM   #1
threezerous
Member
 
Registered: Jul 2009
Posts: 89

Rep: Reputation: 15
Can you pass a bash array to sqplus script?


I have a bash script which collects various values and passes them to a sqlplus script as follows

Code:
sqlplus /nolog << EOF
connect $db_name/$db_password@$db_conn
@test.sql $A $B $C $D 
exit
EOF
Can I define a bash array as below and call something like @test.sql arg[]?
Code:
arg[0]='A'
arg[1]='B'
arg[2]='C'
arg[3]='D'
@test.sql arg[]
 
Old 09-13-2014, 04:47 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
the best thing I can suggest you is to look the man page of bash and look for array handling. It can surely do what you need, but uses different syntax.
Code:
some examples:
a=(A B C D)
echo ${a[0]}
echo ${a[1]}
echo ${a[*]}
 
  


Reply


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
[SOLVED] net snmp pass persist script, can not run a bash script!! Linux Chips Linux - General 4 12-23-2012 02:50 PM
[SOLVED] How can i pass an entire Array into a function parameter by value? (no pointer pass) esgol Programming 26 07-31-2012 12:34 PM
How to pass bash array into awk program Perseus Programming 8 10-25-2011 03:40 AM
[SOLVED] bash how pass array as one of several parameters to a function porphyry5 Programming 5 06-14-2011 10:11 PM
How to pass a c variable to a bash script? daYz Programming 3 09-28-2007 09:30 AM


All times are GMT -5. The time now is 06:33 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