I'm having problems getting a monitoring script to run.  

 

I've put the troublesome bit in a separate script just to test, and it goes
like this:

 

declare -a HN        declares the array "HN"

 

HN=(`echo "SELECT url FROM hosts" | mysql --user=netmon --password=n3tm0n
--skip-column-names check_http`) runs the query and assigns each record to a
new element in the array

 

echo ${#HN}         echo's number of elements in array

 

for ((i=0;i<${#HN};i++)); do

 

        echo ${HN[${i}]}          echo value of each element.

 

done

 

Seems simple enough yeah?! Well if I run echo "SELECT url FROM hosts" |
mysql --user=user --password=pass --skip-column-names check_http at the
command line, i get all of the records - 32. If I run the script above, it
simply refuses to put more than 14 elements in the array.

 

Then, to confuse it even more, if I sort the query, it gives a different
amount depending on what its sorted by!! For example, if I sort it by 'url'
it seems to generate 569 elements! 

 

Can anyone please spot the undoubtedly obvious error I've made here?! I've
been scratching my head for days, to no avail!

 

Many thanks in advance,

 

Ben Benson

 

Reply via email to