Sponsored Content
Top Forums Shell Programming and Scripting How to use array values after the loop. Post 302194832 by Annihilannic on Tuesday 13th of May 2008 07:38:12 PM
Old 05-13-2008
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

It prevents creation of a sub-process to handle the while/read loop, therefore the variables remain in the current scope.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Array values treated as one

I want each integer to be a value/element in the array, however the string is being treated as one. How can I stream these into distinct values? PSF6INDEX=`(snmpwalk -v 2c -c 'H0meru!es' ${SWITCH} .1.3.6.1.2.1.2.2.1.2 | grep 'GigabitEthernet' | sed 's/IF-MIB::ifDescr\.//g' | awk '{print $1}' |... (1 Reply)
Discussion started by: cytriesbash
1 Replies

2. Shell Programming and Scripting

Assigning values to an array via for/while loop

I need to do something like this: for i in 1 2 3 4 5; do arr=$(awk 'NR="$i" { print $2 }' file_with_5_records) done That is, parse a file and assign values to an array in an ascending order relative to the number of record in the file that is being processed on each loop. Is my... (2 Replies)
Discussion started by: fiori_musicali
2 Replies

3. Shell Programming and Scripting

PHP: Search Multi-Dimensional(nested) array and export values of currenly worked on array.

Hi All, I'm writing a nagios check that will see if our ldap servers are in sync... I got the status data into a nested array, I would like to search key of each array and if "OK" is NOT present, echo other key=>values in the current array to a variable so...eg...let take the single array... (1 Reply)
Discussion started by: zeekblack
1 Replies

4. Shell Programming and Scripting

Array Variable being Assigned Values in Loop, But Gone when Loop Completes???

Hello All, Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....? I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping through a string containing some of these "Illegal Characters". Now... (5 Replies)
Discussion started by: mrm5102
5 Replies

5. Red Hat

How to check for values in array?

i stored some values in array , then i traverse through the array and check for some values and if they exist then echo success. let us consider that in our array we stored values from an sql query like this #!/bin/bash declare -a arr arr=$( sqlplus -s rte/rted2@rel76d2 << EOF set... (1 Reply)
Discussion started by: ramsavi
1 Replies

6. Red Hat

Values in array are not able to be used one by one

hey,i stored the value of an sql query in an array and then tried to use that value in while loop. actually my array will have two or more values, then according to the values i have to display result. #!/bin/bash -xv val_1=$( sqlplus -s rte/rted1@rel75d1 << EOF set heading off select... (1 Reply)
Discussion started by: ramsavi
1 Replies

7. Shell Programming and Scripting

awk loop using array:wish to store array values from loop for use outside loop

Here's my code: awk -F '' 'NR==FNR { if (/time/ && $5>10) A=$2" "$3":"$4":"($5-01) else if (/time/ && $5<01) A=$2" "$3":"$4-01":"(59-$5) else if (/time/ && $5<=10) A=$2" "$3":"$4":0"($5-01) else if (/close/) { B=0 n1=n2; ... (2 Replies)
Discussion started by: klane
2 Replies

8. Shell Programming and Scripting

How to swap the values in array using for loop?

array=( 8 5 6 2 3 4 7 1 9 0 ) for i in "${array}" do echo $i done # i need the output like this by swapping of array values 0 9 1 7 4 3 2 6 5 8 (7 Replies)
Discussion started by: Meeran Rizvi
7 Replies

9. Shell Programming and Scripting

Convert values in an array using a loop

I have a headerless array of 1000 columns x 100000 rows. The array only contains 4 values; 0/0, 0/1, 1/1, ./. Here I am showing the 1st 3 rows and columns of the input array 0/0 0/0 1/1 0/1 0/1 0/1 0/0 ./. 0/0 0/0 0/0 0/0 I would like to convert the values in... (9 Replies)
Discussion started by: Geneanalyst
9 Replies

10. Shell Programming and Scripting

Array not printing values if used in a loop

Hello! I'm making an English to Morse Code translator and I was able to mostly get it all working by looking through older posts here; however, I have one small problem. When I run it it's just printing spaces for where the characters should be. It runs the right amount of times, and if I try... (3 Replies)
Discussion started by: arcoleman10
3 Replies
squidclient(1)						      General Commands Manual						    squidclient(1)

NAME
squidclient -- a simple HTTP web client SYNOPSIS
squidclient [-arsv][-A string ][-g count] [-h remote-host] [-H 'string'] [-i IMS] [-I ping-interval] [-j 'Host-header'] [-l local-host] [-m method] [-p port] [-P file] [-t count] [-T timeout] [-u proxy-user] [-U www-user] [-V version] [-w proxy-password] [-W www-password] url DESCRIPTION
squidclient is a tool providing a command line interface for retrieving URLs. Designed for testing any HTTP 0.9, 1.0, or 1.1 web server or proxy. This tool can be combined with scripts to perform any basic HTTP operation. Some additional features for access to the Squid proxy object cache and management information are provided. OPTIONS
-a Do NOT include Accept: header. -A 'string' Send string as User-Agent: header. To omit the header completely set string to empty (''). -g count Ping mode, perform count iterations (0 to loop until interrupted). -h host Retrieve URL from cache on hostname. Default is localhost. -H 'string' Extra headers to send. Use ' ' for new lines. -i time If-Modified-Since time (in Epoch seconds). -I interval Ping interval in seconds (default 1 second). -j hosthdr Host header content -l host Specify a local IP address to bind to. Default is none. -m method Request method, default is GET. Squid also supports a non-standard method called PURGE. You can use that to purge a specific URL from the cache. You need to have purge access setup in squid.conf similar to manager access. Here is an example: acl purge method PURGE http_access deny purge !localhost -p port Port number of cache. Default is 3128. -P file PUT request. Using the named file. -r Force cache to reload URL. -s Silent. Do not print data to stdout. -t count Trace count cache-hops -T timeout Timeout value (seconds) for read/write operations. -u user Proxy authentication username -U user WWW authentication username -v Verbose. Print outgoing message to stderr. -w password Proxy authentication password -W password WWW authentication password -V version HTTP Version. Use '-' for HTTP/0.9 omitted case SEE ALSO
cachemgr.cgi(8), squid(8) AUTHOR
Derived from Harvest. Further developed by by numerous individuals from the internet community. Development is led by Duane Wessels of the National Laboratory for Applied Network Research and funded by the National Science Foundation. Squid Web Client Tool squidclient(1)
All times are GMT -4. The time now is 07:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy