aboutsummaryrefslogtreecommitdiff
path: root/libraries/Bridge/examples/ShellCommands/ShellCommands.ino
blob: 47579f8863815475a5caf8f1c916cff459e13eb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
 Running shell coommands using Process class. 
 
 This sketch demonstrate how to run linux shell commands
 using an Arduino Yún. 

 The circuit:
 * Arduino Yun
 
 created 12 Jun 2013
 by Cristian Maglie
 modified 21 June 2013
 by Tom Igoe
 
 This example code is in the public domain.

 */

#include <Process.h>

void setup() {
  // initialize the Bridge and Serial connections:
  Bridge.begin();
  Serial.begin(9600);
}

void loop() {
  Process p;
  // This command line prints the name of the wireless network
  // that the board is connected to, or the network which the board has created:
  p.runShellCommand(F("lua /usr/lib/lua/pretty_wifi_info.lua | grep SSID"));

  // Read command output
  while (p.available()) {
    char c = p.read();
    Serial.print(c);
  } 
  while (true);    // do nothing more
}