Macos 如何在Mac High上运行VPN自动机
以下是我连接到VPN的代码Macos 如何在Mac High上运行VPN自动机,macos,vpn,macos-sierra,automator,Macos,Vpn,Macos Sierra,Automator,以下是我连接到VPN的代码 VPN="MY VPN NAME" IS_CONNECTED=$(test -z `scutil --nc status "$VPN" | head -n 1 | grep Connected` && echo 0 || echo 1); if [ $IS_CONNECTED = 1 ]; then scutil --nc stop "$VPN" else scutil --nc start "$VPN" fi 但是不断地出错 “应为表达式,
VPN="MY VPN NAME"
IS_CONNECTED=$(test -z `scutil --nc status "$VPN" | head -n 1 | grep Connected` && echo 0 || echo 1);
if [ $IS_CONNECTED = 1 ]; then
scutil --nc stop "$VPN"
else
scutil --nc start "$VPN"
fi
但是不断地出错
“应为表达式,但找到未知标记”
请帮我解决这个问题 如果
已连接
为整数,则需要使用整数比较:
if [ $IS_CONNECTED -eq 1 ]; then
...
对于字符串比较,请使用=
:
if [ "$someString" = "string" ]; then
...