Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 使用Raspberry Pi/Ubuntu/Debian中的shell程序动态切换WiFi_Linux_Shell_Ubuntu_Debian_Raspberry Pi - Fatal编程技术网

Linux 使用Raspberry Pi/Ubuntu/Debian中的shell程序动态切换WiFi

Linux 使用Raspberry Pi/Ubuntu/Debian中的shell程序动态切换WiFi,linux,shell,ubuntu,debian,raspberry-pi,Linux,Shell,Ubuntu,Debian,Raspberry Pi,如何在shell脚本中检查系统是否连接到WiFi-1,如果未连接,如何连接到WiFi-2?我尝试使用wpa_请求程序和接口配置,但没有按预期工作。我跟着这个 如果有其他方法,请告诉我 /etc/网络/接口文件 auto eth0 iface eth0 inet6 manual pre-up ip link set dev eth0 up || true wpa-iface eth0 wpa-driver wired wpa-conf /etc/wpa_suppli

如何在shell脚本中检查系统是否连接到WiFi-1,如果未连接,如何连接到WiFi-2?我尝试使用wpa_请求程序和接口配置,但没有按预期工作。我跟着这个

如果有其他方法,请告诉我

/etc/网络/接口文件

auto eth0
iface eth0 inet6 manual
    pre-up ip link set dev eth0 up || true
    wpa-iface eth0
    wpa-driver wired
    wpa-conf /etc/wpa_supplicant/wpa_supplicant_wired.conf
    pre-down /etc/netplug/netplug eth0 out >/dev/null 2>&1 || true
    post-down ip link set dev eth0 down || true

auto wlan0
iface wlan0 inet manual
      pre-up ip link set dev wlan0 up || true
      wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
      wpa-driver wext
      pre-down /etc/netplug/netplug wlan0 out >/dev/null 2>&1 || true
      post-down ip link set dev wlan0 down || true

# open is specific (IPv6 only) so I just stop dhcp via netplug
iface open inet manual
      up   /etc/netplug/netplug wlan0 out >/dev/null 2>&1 || true

iface default inet manual
      up   /etc/netplug/netplug wlan0 in  >/dev/null 2>&1 || true
      down /etc/netplug/netplug wlan0 out >/dev/null 2>&1 || true

我想你现在可能已经找到了解决办法。无论如何,作为一种解决方法,您可以安装Network manager(支持所有debian发行版,包括ubuntu/raspbian/etc)

然后将所需的网络配置添加到
/etc/NetworkManager/system connections
文件夹中。 wifi网络连接的配置示例如下:

[连接]
id=milanWiFi
uuid=56439211-1067-4334-b199-b73ceed32d83
类型=802-11-wireless
[802-11-无线]
ssid=milanWiFi
模式=基础设施
mac地址=84:3A:4B:9B:CF:66
安全性=802-11-wireless-security
[802-11-wireless-security]
密钥管理=wpa psk
auth alg=打开
psk=米兰123
[ipv4]
方法=自动
[ipv6]
方法=自动
sudo apt-get install network-manager