Re: Loop on mysql output with bash

From: <boubaker.idir_at_abeeway.com>
Date: Fri, 23 Mar 2018 09:35:20 -0700 (PDT)
Message-ID: <2d00a202-328f-4422-9b85-679b261a675b_at_googlegroups.com>


Le lundi 12 mars 2018 17:24:14 UTC+1, Boubaker Idir a écrit :
> Hello everybody, I need to do a loop on my mysql output (packetid) and put it everytime on the second SELECT command, to have a result for each packetid and put it everytime on text file. can you help me please? Thank you so much
>
>
> #!/bin/bash
> array=$(mysql -u root -pMyPassword -s -N <<QUERY_INPUT
> use myDatabase;
> SELECT packetid FROM wifi;
> QUERY_INPUT
> );
>
> echo "${array[_at_]}";
>
> for i in "${array[_at_]}" do
>
> variable=$(mysql -u root -pMyPassword -s -N <<QUERY_INPUT
> use myDatabase;
> SELECT CONCAT("{""wlan"": [",GROUP_CONCAT(JSON_OBJECT("mac",bssid,"powrx",rssi)), "]}") FROM wifi WHERE packetid=$i;
> QUERY_INPUT
> );
>
> echo $variable>text2.txt;
> done

I used php is more useful and more functionalities for json format. Thank you so much guys Received on Fri Mar 23 2018 - 17:35:20 CET

Original text of this message