我在编写脚本时遇到一些麻烦,该脚本将启动我的forticlient vpn命令行客户端并在提示时发送我的密码.这是我的代码:
#!/usr/bin/expect -f
set loadme "./forticlientsslvpncli --server myvpnserver --vpnuser theuser
eval spawn $loadme
expect "Password for VPN: "
send "password\r"
但是,它仍然提示输入vpn密码.我确信这是一个简单的东西,我对linux脚本很新,但任何帮助将不胜感激!
谢谢!
最佳答案
#!/usr/bin/expect -f
set timeout -1
cd /usr/local/forticlientsslvpn
spawn ./forticlientsslvpn_cli --server myhost:10443 --vpnuser myuser
expect "Password for VPN:" {send -- "mypassword\r"}
expect "to this server? (Y/N)\r" {send -- "y\r"}
expect eof