Sponsored Content
Full Discussion: Array values treated as one
Top Forums Shell Programming and Scripting Array values treated as one Post 302215585 by cytriesbash on Wednesday 16th of July 2008 07:39:15 PM
Old 07-16-2008
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[3]} .1.3.6.1.2.1.2.2.1.2 | grep 'GigabitEthernet[3-9]' | sed 's/IF-MIB::ifDescr\.//g' | awk '{print $1}' | tr '\n' ' ')`

output is:

5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78


echo ${PSF6INDEX[0]}

output is:
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh script: 'exit' being treated as 'break 2'

hi, in a korn shell script, has anyone ever seen an 'exit' being treated as a 'break 2'? I have a script which has 3 nested loops. Within the inner most loop, i'm trying to exit the script on a fault condition. instead of exiting, it's acting as a 'break 2' and then continuing on with the... (4 Replies)
Discussion started by: gsatch
4 Replies

2. UNIX for Dummies Questions & Answers

incorrect array values

I have a file with 2 lines and 3 filelds -bash-3.00$ cat del_old_files.cfg $DBA_WORK_DIR *sybdba* 30 $DBA_LOG_DIR *sybdba* 30 I have tried to set up arrays for each field (bash shell) declare -a dirArray=`cut -d' ' -f1 < del_old_files.cfg` declare -a nameArray=`cut -d' ' -f2 <... (6 Replies)
Discussion started by: jhillier
6 Replies

3. Shell Programming and Scripting

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... (1 Reply)
Discussion started by: Devesh5683
1 Replies

4. Shell Programming and Scripting

Assigning the values to an Array

hi every body, i donot know how to assign a array varible with a file see i having file more file property1 Name property2 Address the above two line are tab Space seperated between the property and its value i want to seperate it and assign to... (1 Reply)
Discussion started by: kkraja
1 Replies

5. UNIX for Dummies Questions & Answers

Compare array values

# tail myprocesses.txt 178 processes at Tue Oct 21 14:33:01 IST 2008 16 MySQL processes at Tue Oct 21 14:33:01 IST 2008 175 processes at Tue Oct 21 14:36:01 IST 2008 60 MySQL processes at Tue Oct 21 14:36:01 IST 2008 192 processes at Tue Oct 21 14:39:01 IST 2008 64 MySQL processes at Tue Oct... (2 Replies)
Discussion started by: shantanuo
2 Replies

6. Shell Programming and Scripting

integer treated as text?

The following script should kill all the queries taking more than say 600 seconds. But it seems that it is killing queries taking more than 6 seconds. >> sh myscript.sh 600 #!/bin/bash #kill runaway processes SEC=$1 ifs='|' if ]; then echo "Usage: $0 seconds" exit 1 fi mysqladmin... (4 Replies)
Discussion started by: shantanuo
4 Replies

7. 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

8. Shell Programming and Scripting

reading values into an array

I have this portion of a script and it works: base_config="A B C D E" for field in $base_config do var=`echo $field` ((i=$i+1)) done I get an array of var=A, var=B, and so on. What if I have this example with white space and want to put it into an array while... (1 Reply)
Discussion started by: djehresmann
1 Replies

9. 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

10. 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
SNMPREALWALK(3) 							 1							   SNMPREALWALK(3)

snmprealwalk - Return all objects including their respective object ID within the specified one

SYNOPSIS
array snmprealwalk (string $host, string $community, string $object_id, [int $timeout = 1000000], [int $retries = 5]) DESCRIPTION
The snmprealwalk(3) function is used to traverse over a number of SNMP objects starting from $object_id and return not only their values but also their object ids. PARAMETERS
o $host -The hostname of the SNMP agent (server). o $community -The read community. o $object_id -The SNMP object id which precedes the wanted one. o $timeout -The number of microseconds until the first timeout. o $retries -The number of times to retry if timeouts occur. RETURN VALUES
Returns an associative array of the SNMP object ids and their values on success or FALSE on error. In case of an error, an E_WARNING mes- sage is shown. EXAMPLES
Example #1 Using snmprealwalk(3) <?php print_r(snmprealwalk("localhost", "public", "IF-MIB::ifName")); ?> The above will output something like: Array ( [IF-MIB::ifName.1] => STRING: lo [IF-MIB::ifName.2] => STRING: eth0 [IF-MIB::ifName.3] => STRING: eth2 [IF-MIB::ifName.4] => STRING: sit0 [IF-MIB::ifName.5] => STRING: sixxs ) SEE ALSO
snmpwalk(3). PHP Documentation Group SNMPREALWALK(3)
All times are GMT -4. The time now is 07:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy