检查 NordVPN bash 脚本的连接状态

问题描述 投票:0回答:1

我正在尝试检查我的计算机是否已通过 VPN (NORDVPN) 连接

我的 bash 脚本如下:

STATUS = "$(nordvpn status | head -n 1)"
printf "STATUS %s\n" "$STATUS"

if [[ $STATUS == "Status: Disconnected" ]]
then
        echo "Disconnected from VPN..."
        nordvpn connect Salt_Lake_City
fi

我得到以下输出:

STATUS: command not found
STATUS 

提前致谢

bash variables compare
1个回答
0
投票

我会做什么:

status="$(nordvpn status | head -n 1)"
printf "status %s\n" "$status"

if [[ $status == "Status: Disconnected" ]]
then
    echo "Disconnected from VPN..."
    nordvpn connect Salt_Lake_City
fi
© www.soinside.com 2019 - 2024. All rights reserved.