Adding begin of Golang setupKit implementation

This commit is contained in:
Philippe Caseiro 2018-09-18 16:32:58 +02:00
parent 2421071da6
commit 267017bdc1

View File

@ -0,0 +1,38 @@
package main
import (
"bytes"
"fmt"
"log"
"os/exec"
)
func scanWifi(iface string) string {
command := "iwinfo"
opt := "scan"
var out bytes.Buffer
var stderr bytes.Buffer
fmt.Printf("Running %s command\n", command)
exe := exec.Command(command, iface, opt)
exe.Stdout = &out
exe.Stderr = &stderr
err := exe.Run()
if err != nil {
fmt.Println(fmt.Sprint(err) + ": " + stderr.String())
log.Fatal(err)
}
return out.String()
}
func getCellInfo(iface string, ssidPrefix string) {
cells := scanWifi(iface)
fmt.Printf("%s\n", cells)
}
func main() {
getCellInfo("wlan1", "Base1")
}