Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have a bash script that is running an SNMPGET of two values. I want to take the results and put them in an array.

Here is the code:

OUTPUT=`snmpget -v2c -c public -Oqv 192.168.0.33' \
' sysName'\
' SysLocation'
echo  $OUTPUT
ARRAY=($OUTPUT)
echo ${ARRAY[0]}

echo $OUTPUT returns "Private Network" "Server 4 ".

When I put it in an array and do:

echo ${ARRAY[0]}

it Returns "Private

How do I alter my script so that the qualifier for the array, is not the space in between words so for echo ${ARRAY[0]} it Returns "Private Network"?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Replace

ARRAY=($OUTPUT)

by

eval ARRAY=($OUTPUT)
share|improve this answer
    
thank you, that did the trick.... –  user2179455 Apr 4 at 9:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.