package main
import (
"fmt"
"log"
"os/exec"
"strings"
)
func doCmd(cmd string) string {
parts := strings.Fields(cmd)
head := parts[0]
parts = parts[1:len(parts)]
out, err := exec.Command(head, parts...).Output()
if err != nil {
log.Fatal(err)
}
return string(out)
}
func main() {
cmd := "netsh wlan show networks mode=bssid"
out := doCmd(cmd)
fmt.Printf("%s\n", out)
}
No comments:
Post a Comment