![](/img/trans.png)
[英]Python script doesn't return values altough program runs correctly interactively(windows10 cmd)
[英]Translating WiFi switching Linux shell script to Windows10 CMD or PowerShell
我设法创建了一个 Linux shell 脚本,该脚本能够在两个经常挂起但可以手动重新连接成功的不同 wifi 服务之间切换。
while (true) do
if ! [ "`ping -c 1 -W 1 www.google.it`" ]; then
if (nmcli connection show --active | grep -c "FirstWiFi"); then
nmcli connection up id "SecondWiFi"
echo "switched to SecondWiFi"
else
nmcli connection up id "FirstWiFi"
echo "switched to FirstWiFi"
fi
fi
done
我不建议使用这个脚本,因为我不知道它是否安全。
现在我需要在 Windows 10 系统上使用相同的功能。
我知道 CMD 比 bash shell 等更受限制。 但 Windows 10 也有 PowerShell。
如您所见,脚本非常简单,因此我认为可以翻译。 我不知道怎么做。
也许可以在这里找到一些简单的建议。
我没有 nmcli,但它是这样的:
while ($true) {
if (! (test-connection www.google.it -count 1 -ea 0)) {
if (nmcli connection show --active | select-string FirstWiFi) {
nmcli connection up id "SecondWiFi"
echo "switched to SecondWiFi"
} else {
nmcli connection up id "FirstWiFi"
echo "switched to FirstWiFi"
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.