![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| incorrect array values | jhillier | UNIX for Dummies Questions & Answers | 6 | 01-04-2008 12:44 AM |
| printing all array values using dbx 7.2.1 | JamesGoh | High Level Programming | 1 | 12-18-2007 12:07 PM |
| to assign cut values to an array | Syms | UNIX for Dummies Questions & Answers | 6 | 10-29-2007 02:42 AM |
| Assigning values to an array | yongho | UNIX for Dummies Questions & Answers | 4 | 07-13-2005 05:49 PM |
| array values in a command | eeisken | Shell Programming and Scripting | 3 | 06-22-2005 01:49 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
How to use array values after the loop.
- I m retreving values from database and wish to use those values later in my shell script. I m placing these values in an array da_data but outside loop array is empty.Problem is its treating array as local inside loop hence array is empty outside loop.
Plz go through the script and suggest how to use array values after the loop. declare -a da_data count=0 cat $LOAD_DA_FILE | \ while read da_name do da_data[count]=`$ORACLE_HOME/bin/sqlplus -s username/password@instance << EOF set heading off set feed off select start_date from table where derive_name='$da_name'; EXIT EOF` count=`expr $count + 1` echo ${da_data[count-1]} # displaying array value done echo -n "Elements Of array : " echo ${da_data[@]} # array empty - thanks in advance |
| Forum Sponsor | ||
|
|
|
|||
|
Try this instead:
Code:
declare -a da_data
count=0
while read da_name
do
da_data[count]=`$ORACLE_HOME/bin/sqlplus -s username/password@instance << EOF
set heading off
set feed off
select start_date from table where derive_name='$da_name';
EXIT
EOF`
count=`expr $count + 1`
echo ${da_data[count-1]} # displaying array value
done < $LOAD_DA_FILE
echo -n "Elements Of array : "
echo ${da_data[@]} # array empty
|
|||
| Google UNIX.COM |