Tuesday, July 19, 2016

How To Make IoT Messaging with BashShell

Create new file with extension .sh ..
As you know the first line of Bash Script start with this

okay, let's say we want collect information of our IoT like Memory and IP Address etc..
so we can collect this information with Shell Script.

# Get Used Memory
um=$(free -h | grep Mem | awk ' { print $3 } ')
# Get Free Memory
fm=$(free -h | grep Mem | awk ' { print $2 } ')
# Get Local IP Address
ipadd=$(ifconfig wlp3s0b1 | grep 'inet ' | awk '{print $2}')
# Get Public IP Address
pip=$(curl iblo.esy.es)
Okay We Are Done, We collect all information that we need to save, so we need name for our IoT, let's make it complex .
Now we put all Variables in one Variable
Now let's Save our Data
output=$(curl -X POST $URL)
the output variable should be like this :
New Name http://www.iblo.esy.es/load/data/?iot=rasp5289166
Note it respond with "New Name" and the link of your saved data.
if we save data again the output looks like this :

Overwritten http://www.iblo.esy.es/load/data/?iot=rasp5289166