使用golang的可用无线网络列表(在Linux下) [英] List of available wireless networks with golang (under Linux)

查看:1291
本文介绍了使用golang的可用无线网络列表(在Linux下)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取在Linux操作系统下运行的Go程序中可用的无线网络列表。很容易从iwlist的Linux命令行获取这些信息,但我真的想在Go中本地完成。任何想法的包应该使用?谢谢。

I would like to get a list of the wireless networks available inside a Go program running under Linux OS. It's pretty easy to get this information from a Linux command line with iwlist but I really want to have it done natively in Go. Any ideas of which package should be used? Thank you.

推荐答案

我能够通过执行Linux命令获取信息。下面是一段代码:

I was able to get the information by executing a Linux command. Here's the piece of code:

    iwlistCmd := exec.Command("iwlist", iface, "scan")
    iwlistCmdOut, err := iwlistCmd.Output()
    if err != nil {
        fmt.Println(err, "Error when getting the interface information.")
    } else {
        fmt.Println(string(iwlistCmdOut))
    }

列表信息和工作在Linux只。作为下一个stel我必须找到一种方法来提取我需要的是ESSID可能与strings.split包/函数。

The output is a huge list of information and works in Linux only. As a next stel I have to find a way to extract the info I need which is the ESSID probably with strings.split package/function.

这篇关于使用golang的可用无线网络列表(在Linux下)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆