I only see topics passing js values to a bash script. I want values from a bash script to be used in a javascript.
What I want:
Based on a signal-number, a different icon should be displayed on my webpage. The signal-number needs to be checked every 5 seconds so the icon can be updated accordingly. (Like the signal quality bar on a mobile phone).
What I have:
A bash file called signal.sh which contains the following line to execute:
/usr/bin/pretty-wifi-info.lua | grep 'Signal' | tr '%' ' ' | awk '{printf "{\"Signal\":"$2"}"}'
The output from that script is (for example):
{"Signal":55}
In other words a JSON-object. The bash script is located on my server at /www/signal.sh
What I want to know:
1) How can I use javascript to run this bash script, get that json-object out and use the number to do a calculation in js on my website (pretty much like using setInterval to re-run a php-file that ouputs a json-obj get the info stored in a variable and than update a div with that new variable).
2) How to attach a different icon to a specific value.
About the first one. I really don't have a clue!
The latter should -I think- be a if, else if, else statement that depending on the outcome returns a specific img_src which is used to display the icon in a < div> or on a < span> which updates every 5 seconds.
Hope someone can help!
UPDATE
I ticket MichaelWclark's answer as the correct one. I used his info to display the correct icon. I decided not to go down the road of node.js but use a php file instead that reads the bash script.