39 lines
602 B
Go
39 lines
602 B
Go
|
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")
|
||
|
}
|