Array as a Parameter


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Array as a Parameter
# 1  
Old 03-30-2006
Array as a Parameter

In a ksh shell... I need to pass 12 parameters to a secondary ksh shell. In VB I would just pass an array that contains all of these, but haven't been successful in passing the full array in a KSH shell.

Does anyone have an example where you can pass an array as a parameter?

here's what i have so far on the one doing the invoking..

.
.
set -A arryCompare $strEnv1Name $strEnv1User $strEnv1Pass $strEnv2Name $strEnv2User $strEnv2Pass $strDbName $strEleType $strDirResult $strDirDiff $strDirTemp $strCCaseInd

st09_Syb_Comp_List.sh $(arryCompare)
.
.

Thanks for any and all responses on this.
Harold
# 2  
Old 03-30-2006
Tools solution found

okay... I found a solution for the problem... but any other solutions are welcomed.

in Script 1:
.
.
set -A arryCompare $strEnv1Name $strEnv1User $strEnv1Pass $strEnv2Name $strEnv2User $strEnv2Pass $strDbName $strEleType $strDirResult $strDirDiff $strDirTemp $strCCaseInd

st09_Syb_Comp_List.sh "$(arryCompare[*])"
.
.

in Script 2: ... st09_Syb_Comp_List.sh
.
set -A arryCompare $1
.
.
.
Thanks, Smilie Smilie
Harold
# 3  
Old 03-30-2006
You are cramming all of your array elements from script 1 into a single large array element in script 2.

In script 1 you need:
t09_Syb_Comp_List.sh "$(arryCompare[@])"

In script 2 you need:
set -A arryCompare "$@"

to keep the arrays similiar.
# 4  
Old 03-31-2006
Thanks...

Thanks for posting the fix. That solved a problem that I hadn't found till this morning.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Call Script with Parameter (that has another parameter)

Hi. How do I achieve this sh /EDWH-DMT02/script/MISC/exec_sql.sh "@/EDWH-DMT02/script/others/CSM_CKC/Complete_List.sql ${file_name}" Complete_List.txt The /EDWH-DMT02/script/MISC/exec_sql.sh has two parameters and it's working fine with this sh /EDWH-DMT02/script/MISC/exec_sql.sh... (7 Replies)
Discussion started by: aimy
7 Replies

2. Shell Programming and Scripting

Resolving a parameter which is passed as parameter

Hi, I have the following files. ->cat scr.sh export TMP_DIR=/home/user/folder1 export TMP_DIR_2=/home/user/folder2 while read line do cat "$line" done<file_list.dat ------------------------ -> cat file_list.dat $TMP_DIR/file1.txt $TMP_DIR_2/file2.txt --------------------------- -> cat... (6 Replies)
Discussion started by: barath
6 Replies

3. Shell Programming and Scripting

How to get the parameter value from the parameter file in perl?

hi all, i have a parameter file of following format, i want a method which can get the value of specific parameter. parameter file format: <Parameter Name="FileLocationWindows"> <Description> The directory location of the logger file. ... (1 Reply)
Discussion started by: laxmikant.hcl
1 Replies

4. Shell Programming and Scripting

Attempting to pass my array as a nested parameter to loop. A little lost.

I want to pass this array as a parameter. IFS=$'\n' fortune_lines=($(fortune | fold -w 30 )) Inside of this line screen -p 0 -S ${SCREEN_SESSION} -X stuff "`printf "say ${fortune_lines}\r"`" And I am lost at this point. I am thinking something like this? Then make it loop.. ... (7 Replies)
Discussion started by: briandanielz
7 Replies

5. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

6. Shell Programming and Scripting

Command that takes one parameter and then searches for the passed in parameter

Hi I am looking for a unix command or a small shell script which can takes one parameter and then searches for the passed in the parameter in any or all files under say /home/dev/ Can anyone please help me on this? (3 Replies)
Discussion started by: pankaj80
3 Replies

7. Shell Programming and Scripting

using an awk internal variable as parameter for an external array

Hello, I am running a bash script under linux which first defines an CA-array like j=0 num1=120.00 num2=10.00 until do CA='echo $num1 + $j*$num2' j=$ done within the later awk section of this same script I want to read data from a file. If the value of the second column is... (3 Replies)
Discussion started by: MotAah
3 Replies

8. Shell Programming and Scripting

Parameter Problem With an Array Variable

Hi, I have two bash shell scripts: test: rrdhcp78-120:test_data msb65$ cat ~/bin/test #!/bin/sh array1=() echo 'elements in array1:' ${#array1} ~/bin/test2 $array1 test2: rrdhcp78-120:test_data msb65$ cat ~/bin/test2 #!/bin/sh array2=${1} (5 Replies)
Discussion started by: msb65
5 Replies

9. Shell Programming and Scripting

how do I make dynamic parameter names? Or get the value of a parameter evaluated twi

Say I write something like the following: var1=1 var2=2 for int in 1 2 do echo "\$var$int" done I want the output to be: 1 2 Instead I get something like: $var1 $var2 (2 Replies)
Discussion started by: Awanka
2 Replies

10. UNIX for Dummies Questions & Answers

Array as parameter

Can I pass and array as a function paramter? #!/bin/bash a1=one a1=two a2=one a2=two function f1() { array1copy=( ${1} ) array2copy=( ${2} ) echo "${array1copy}" echo "${array2copy}" } f1 "${a1}" "${a2}" (2 Replies)
Discussion started by: newbreed1
2 Replies
Login or Register to Ask a Question