LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 10:35 AM   #1
threezerous
Member
 
Registered: Jul 2009
Posts: 96

Rep: Reputation: 16
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, 03:47 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,830

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
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



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 01: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 11:34 AM
How to pass bash array into awk program Perseus Programming 8 10-25-2011 02:40 AM
[SOLVED] bash how pass array as one of several parameters to a function porphyry5 Programming 5 06-14-2011 09:11 PM
How to pass a c variable to a bash script? daYz Programming 3 09-28-2007 08:30 AM

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

All times are GMT -5. The time now is 10:47 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
Open Source Consulting | Domain Registration