-1

I want to collect values to a array in C using system().

With:

hcidump -a | egrep 'RSSI|bdaddr' | grep -A1 --no-group-separator 'bdaddr 78:A5:04:17:9F:66' | grep -Po 'RSSI:\s+\K.*'

an output like that:

-25
-24
-23
-26
-26

and want to store that values in an array in C, but that's not possible, I assume, with:

system("hcidump -a | egrep 'RSSI|bdaddr' | grep -A1 --no-group-separator 'bdaddr 78:A5:04:17:9F:66' | grep -Po 'RSSI:\s+\K.*'");

Has anybody an idea if there is a command to achieve that? or a workaroung? My only idea is to write the data into a file and afterwards read the information out of it, but I would like to have a better approch.

Best regards Adrian

AdrianL
  • 335
  • 2
  • 18

1 Answers1

2

Use the link and execute the command and inside the while loop, store each and every line in the array. Your job is done.

Vijay
  • 65,327
  • 90
  • 227
  • 319