1

Running shell command through Bridge in Arduino Yun through a Process let's say, proc, it gives result and we can read the result bytes using following piece of code.

#include <Bridge.h>
#include <Process.h>

void setup() {
  Bridge.begin();
  Serial.begin(9600);
  while (!Serial);
}

void loop() {
    Process proc;
    proc.runShellCommand("ls /root/");
    while (proc.available() > 0)
        Serial.print((char)proc.read());
    Serial.println();
}

What if I have to access data from a blocking shell command as it gets updated like and event? Such as, some consumer that listens to Kafka or Mosquitto subscribed topic. Whenever that topic is updated/published with new data, the listener gets it.

How can I model such structure using Arduino Yun program using Bridge.

Fahad Siddiqui
  • 1,829
  • 1
  • 19
  • 41

1 Answers1

1

You can do it quite easily. Run that particular command with nohup, in that case, file with the name nohup.out would be created. then after that run a script that continuously monitors that nohup.out file in case of any change in the size of nohup.out, get the latest data and push that data to anywhere you want.

Mukrram Rahman
  • 426
  • 2
  • 14