汉斯的回答
随心所欲 -谢谢!-我想略微简化调用,绕过Terminal并以macOS状态菜单中的AnyConnect图标结束。(我使用的是莫哈韦语10.14.6。)
首先,启动终端,然后切换到AnyConnect应用程序二进制文件的目录:
$ cd "/Applications/Cisco/Cisco AnyConnect Secure Mobility Client.app/Contents/MacOS"
复制原始二进制文件:
$ sudo cp \
"Cisco AnyConnect Secure Mobility Client" \
"Cisco AnyConnect Secure Mobility Client.orig"
最后,覆盖了shell脚本的初始文件,改变VPN host
你的VPN主机名或地址,user
并pa$$w0rd
给您的凭证:
$ sudo cat > "Cisco AnyConnect Secure Mobility Client" <<'SCRIPT'
#!/bin/sh
# The AnyConnect vpn utility takes some options and commands or
# else runs interactively. The help command shows that -s reads
# a script from STDIN and that connect takes a host as argument.
# connect gets the username and password from STDIN. We will
# supply them from a heredoc with the -s option.
/opt/cisco/anyconnect/bin/vpn -s \
connect "VPN host" <<'CREDENTIALS'
user
pa$$w0rd
CREDENTIALS
exec "$0.orig" # invoke the original app
SCRIPT
现在,您应该能够像往常一样从Spotlight或Finder运行AnyConnect。首先,我们的脚本将连接,然后将执行移交给应用程序二进制文件,因此AnyConnect将出现在桌面的“状态菜单”上。