在 Android 上通过 bash 脚本启用/禁用 wifi
我正在尝试在 bash 脚本中启用/禁用 Android 设备中的 wifi 设备。我正在使用终端仿真器和程序脚本管理器在手机(是 root 的 Nexus One)上执行 bash 脚本。 在 Linux 中执行此操作的正常方法是这样的
ifconfig eth0 up
That Gives me
"eth0: no such device"
Trying iwconfig eth0
给出相同的结果,并
iwconfig
给出没有 eth0 的设备列表。现在,如果我打开 wifi(从 GUI 手动)并键入,
iwconfig
它会显示 eth0 以及大量信息。
我的问题是:如何使用命令行打开/关闭wifi?为什么当 wifi 被禁用时 eth0 从设备列表中消失?
谢谢。
I am trying to enable / disable the wifi device in my android device in a bash script. I am using the terminal emulator and the program Script Manager to execute bash scripts on the phone (which is a rooted Nexus One).
The normal way to do this in linux would be something like
ifconfig eth0 up
That gives me
"eth0: no such device"
Tryingiwconfig eth0
gives the same, and
iwconfig
gives a list of devices with no eth0 on it. Now if I turn on wifi (manually from the GUI) and type
iwconfig
it shows eth0 with a lot of info.
My question is: How can I use the command line to turn on / off wifi? And why is eth0 disappearing from the device list when wifi is disabled?
thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然由于显而易见的原因,它在我的未 root 手机中不起作用,但在连接 wifi 时,我获得的结果完全不同:
如果您只想打开或关闭 wifi,则应该使用:
或
查看帮助消息
While it doesn't work in my non-rooted phone for obvious reasons, the results I'm obtaining are completely different while wifi is connected:
If you just want to turn wifi on or off you should use:
or
to see the help message